I have a problem when trying to send two inserts at once. The table has a primary key with automatic increment. Installed comment objects do not have an identifier set so that the database can assign it.
My code works for single inserts, if I send right away, but if I try to execute several InsertOnSubmit commands, then it does not seem to matter and does not return any errors or exceptions, even if my code is in a try and catch block. Has anyone else had this problem or do you know which direction I should look?
Example 1 (this does not commit the database)
//myComment is initialised with data
dc.tblDailyComments.InsertOnSubmit(myComment);
//myComment2 is initialised with different data
dc.tblDailyComments.InsertOnSubmit(myComment2);
//when this is called it does not commit to the database
dc.SubmitChanges();
Example 2 (this works great)
dc.tblDailyComments.InsertOnSubmit(myComment);
dc.SubmitChanges();
dc.tblDailyComments.InsertOnSubmit(myComment2);
dc.SubmitChanges();