I have created one function whose purpose is to add data to database (I’m using linq to sql)
This is the code I have written
public static void Add(string Name, int Quantitty) {
DataDataContext Database = new DataDataContext();
tests test = new tests();
test.Name = Name;
test.Quantity = (short)Quantitty;
Database.tests.InsertOnSubmit(test);
Database.SubmitChanges();
}
I have opened my application, pressed the button which calls this function and closed application, than I have opened table data in VS and there was no data in database.
I dont understand what I’m doing wrong.
Are you using a local database file (e.g. Database1.sdf)? If this is the case, the database gets copied to the bin folder when you build your app, which then uses that copy. The application is adding data to a different file than the one VS is opening.