I'm not a very experienced programmer and am currently using Microsoft Visual Studio Express 2013 for Windows Desktop for my coursework project.
I am currently trying to add a new record (I think it's called a record, I mean row) to my TeacherDetails table using LINQ to SQL however whenever I click on button2 an error comes up saying :
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.Linq.dll
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
(Which I'm not really sure means)
Whenever I press continue and try refresh my table/ database another error appears saying:
This database cannot be imported. It is either an unsupported SQL Server version or an unsupported database compatibility
This is the code that I am using to try and insert the record:
private void button2_Click(object sender, EventArgs e)
{
ProjectDBDataContext db = new ProjectDBDataContext(@"projectDB.mdf");
TeacherDetail cust = new TeacherDetail();
cust.Surname = "Surname";
cust.First_Name = "name";
cust.Email_Address = "smckay@email.co.uk";
cust.Title = "Mr";
db.TeacherDetails.InsertOnSubmit(cust);
db.SubmitChanges();
this.Hide();
Form1 f1 = new Form1();
f1.ShowDialog();
}
This is my database code thingy:
CREATE TABLE [dbo].[TeacherDetails] (
[TeacherId] INT IDENTITY (1, 1) NOT NULL,
[First Name] NVARCHAR (50) NULL,
[Surname] NVARCHAR (50) NULL,
[Email Address] NVARCHAR (50) NULL,
[Password] NVARCHAR (50) NULL,
[Title] NVARCHAR (50) NULL,
[Username] NVARCHAR (50) NULL,
CONSTRAINT [PK_TeacherDetails] PRIMARY KEY CLUSTERED ([TeacherId] ASC)
);
I would be so very grateful if someone could help me solve my problem if so then please don't use very complex wording because I'm a bit of a coding newbie.
Thomas