views:

172

answers:

2

Working on Access 2007 and Visual Studio 2008, i already connected my database to the application and can see the data on datagrids and can add or edit or delete records, the problem is that those changes do not go to the database, so when i close and reopen the application, i found the old data as it was before. Note: i used the wizard to add the connection, not the code.

+1  A: 

You'll have to take a look at the OleDbDataAdapter class, check out the UpdateCommand / InsertCommand / etc... properties, assign an OleDbCommand to those properties and make sure that those commands have the appropriate SQL statements.

I suppose you're using DataSets/DataTables that are bound to the datagrid. When you make changes , the changes will be made in the DataTable object. For each row that has been changed, the RowState property for that row will be modified.

If you call the 'Update()' method of the DataAdapter, then the DataAdapter will look at which rows have been changed, and it will execute the correct OleDbCommand for that Row.

This will make sure that the changes are persisted in the database.
Afterwards, you'll have to make sure that you call the 'AcceptChanges' method of the DataTable or Dataset.

But, there are numerous tutorials out there ... tutorials

Frederik Gheysels
A: 

tanga ka naglagay kapa ng post

sad