I am new to working with ADO.net
- I am using an Access database to hold my data
- At run time I create a dataset and can populate my data
- One of the datatables in the dataset is named "tblEmployeeHours"
- I have a dataadapter called "daEmployeeHours" that is used to fill the datatable
- I have a variable called "tblEmployeeHours" which references the datatable with the same name
The datatable is not bound to any UI control, but I am able to make updates to the datatable by code and verify that the datatable has been updated.
I am trying to save the updates back to the database, but nothing happens and I get no error messages
Since I built the dataadapter at runtime, I believe I also have to build the update command and define the parameters. Here is my code
Code:
strSql = "UPDATE tblEmployee_ProjectHours SET plannedHours = @plannedHours"
Me.daEmployeeHours.UpdateCommand = New OleDb.OleDbCommand(strSql, Me.conn)
Me.daEmployeeHours.UpdateCommand.Parameters.Add("@plannedHours", OleDb.OleDbType.Decimal)
Me.daEmployeeHours.UpdateCommand.Parameters("@plannedHours").SourceColumn = "plannedHours"
Me.daEmployeeHours.Update(tblEmployeeHours)
Not sure if I built the update command and parameters correctly, and not sure of how to even error check this. The table in the database has a primary key. My understanding is that the datatable records which records have been updated, added, or deleted. Any suggestions or recommendations would be appreciated. Thanks.