Thursday, March 8, 2012

Data changes in SQLExpress not committed?

Hello,

I am developing an application with a SQLExpress database. The database contains a very simple table, and I have added a Dataset object to the solution, and generated a plain Adapter object in the Dataset (using the standard VS wizard capabilities) to operate on one of the tables in de database. Just plain SELECT, INSERT operations, etc.

Strange thing is, the data changes caused by the adapter's generated Insert command (which will call the INSERT statement on the database) are only visible while the application runs (or so it seems). For example:

- I start off with the table containing 2 records, and start debugging
- perform a COUNT within the code: 2 records
- call the Insert function once from code
- perform a COUNT within the code: 3 records
- stop debugging
- inspect the table: the 3rd record doesn't exist, just the 2 records

So, it seems that the changes don't get committed, although I am not sure it is a transaction/commit problem. I haven't been able to figure out what I can do to fix this. I have used adapters before on a SQL database, no problems there. Any comments appreciated.

Cheers, JP

Try to call SqlDataAdapter.Update method after inserting recordsSmile Please take a look at this link:

http://msdn2.microsoft.com/en-us/library/33y2221y(d=ide).aspx

No comments:

Post a Comment