views:

23

answers:

1

Hi Friends,

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  A: 

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.

Randy Minder