Hi
Im using a DataGrid to display and modify a table from an Access DB.
To do this I create a DataSet and fill it with MS Access database.
I then bind the DataGrid to the Dataset so the datagrid automatically displays everything.
I would like to use this DataGrid as my main editing for the Database including Updating/Deleting/Inserting.
But im having trouble working out If i need to insert/update or delete.
Basically when my application closes I wish to save the contents of the DataGrid ( which is binded to a DataSet ) back into a table in a MDB.
So users can delete rows, add rows and update rows.
Then when they exit, I wish to update the MDB table with all the changes from the DataSet.
How can I do this?
Currently this is what im doing
VB Code:
Dim oCB As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(oAdp) Dim oComm As OleDb.OleDbCommand = oCB.GetUpdateCommand() Try '-- Updates the Database with the new item list oAdp.Update(dsMyItems, "MyItems") Catch ex As OleDb.OleDbException Console.WriteLine(ex.Message) End Try '-- Close the connection, we dont need to keep it open (or do we?) oConn.Close()
but the Try code catches an error when records have been added or delete.




Reply With Quote