0
votes

I have created LINQ to SQL Class and trying to insert one record in application but unable to save record in database table in window application

Table Name : Test

I have two column in table

1) TID Type INT , Primary Key , Identity column 2) Title Type Varchar(50)

I have written below code to save new record in to table, Code running successfully without any error but record not store into application

My code is

 DataClasses1DataContext db = new DataClasses1DataContext();
        Test t = new Test();
        t.Title = "Abhishek";
        db.Tests.InsertOnSubmit(t);
        db.SubmitChanges();

please help me to resolve this problem

Thanks, Abhishek

1
The error you get is there for a reason! post it! - Nick Craver

1 Answers

1
votes

Your code looks fine. But, just before calling SubmitChanges, take a look at db.GetChangeSet() and see if there are any pending inserts. There should be one. If there is one, take a look at the db.Log output and see what is getting sent to SQL Server.