Hi.
I have a DataGridView which is bound to a DataSet. The data comes from multiple tables with join statements, therefore, I am unable to use the SQLCommand builder to automatically update the data.
When the data is loaded in the grid, it will contain multiple rows (with a hidden primary key field). The user needs to change the data in 1 of the columns and save the data back to the database with the tableadapter.Update command.
The database is SQL
I have written the update statement but I don't know how to pass the correct parameters to it. Because it is a bulk update, I don't know how to make the correct rows get updated with the correct data. Here's my update statement and the parameters I am trying to pass.
When I run the code, I get the following error.
"No mapping exists from object type System.Windows.Forms.DataGridViewTextBoxColumn to a known managed provider native type."
I know I haven't mapped the fields correctly but I don't know how else to do it.
Please can someone help me.
Thanks
I have a DataGridView which is bound to a DataSet. The data comes from multiple tables with join statements, therefore, I am unable to use the SQLCommand builder to automatically update the data.
When the data is loaded in the grid, it will contain multiple rows (with a hidden primary key field). The user needs to change the data in 1 of the columns and save the data back to the database with the tableadapter.Update command.
The database is SQL
I have written the update statement but I don't know how to pass the correct parameters to it. Because it is a bulk update, I don't know how to make the correct rows get updated with the correct data. Here's my update statement and the parameters I am trying to pass.
VB.NET:
MyExpenseLinesAdapter.UpdateCommand = New SqlCommand
MyExpenseLinesAdapter.UpdateCommand.Connection = MyPhantomConn
MyExpenseLinesAdapter.UpdateCommand.CommandText = "UPDATE ExpenseLines SET ApprovedAmt = @ApprovedAmt WHERE ExpenseLineID = @ExpenseLineID"
MyExpenseLinesAdapter.UpdateCommand.Parameters.AddWithValue("@ApprovedAmt", ApprovedAmt)
MyExpenseLinesAdapter.UpdateCommand.Parameters.AddWithValue("@ExpenseLineID", ExpenseLineID)
MyExpenseLinesAdapter.Update(MyExpenseLinesDataSet, "ExpenseLines")
When I run the code, I get the following error.
"No mapping exists from object type System.Windows.Forms.DataGridViewTextBoxColumn to a known managed provider native type."
I know I haven't mapped the fields correctly but I don't know how else to do it.
Please can someone help me.
Thanks