How to update a TableAdapter
-
Hi, I’m new to ADO.Net and I’m using VB.Net 2005. I have created a form which has a Data Grid, a ‘Show Data’ button and a ‘Update’ button. Also I have created a BindingSource, a TableAdapter and a DataSet. BindingSource is connected to an Access Database. I can get data by using
Me.myTableTableAdapter.Fill(Me.DBDataSet.myTable)
But when I tried to update the TabelAdapterMe.myTableTableAdapter.Update(Me.DBDataSet.myTable)
I received an error “Update requires a valid UpdateCommand when passed DataRow collection with modified rows.” Then I double clicked the ‘DBDataSet.xsd’ on the Solution Explorer window and I selected myTableTableAdapter and created a new UpdateCommand Now I receive an error “Command text was not set for the command object.” I do not know what I have to do next:confused: Please Help me Thank you chatura -
Hi, I’m new to ADO.Net and I’m using VB.Net 2005. I have created a form which has a Data Grid, a ‘Show Data’ button and a ‘Update’ button. Also I have created a BindingSource, a TableAdapter and a DataSet. BindingSource is connected to an Access Database. I can get data by using
Me.myTableTableAdapter.Fill(Me.DBDataSet.myTable)
But when I tried to update the TabelAdapterMe.myTableTableAdapter.Update(Me.DBDataSet.myTable)
I received an error “Update requires a valid UpdateCommand when passed DataRow collection with modified rows.” Then I double clicked the ‘DBDataSet.xsd’ on the Solution Explorer window and I selected myTableTableAdapter and created a new UpdateCommand Now I receive an error “Command text was not set for the command object.” I do not know what I have to do next:confused: Please Help me Thank you chaturaFirst create a command builder and then update the Data Adapter. Dim CB As New OLEDBCommandBuilder(myTableTableAdapter) Me.myTableTableAdapter.Update(Me.DBDataSet.myTable) With Best Regards, Mayur
-
First create a command builder and then update the Data Adapter. Dim CB As New OLEDBCommandBuilder(myTableTableAdapter) Me.myTableTableAdapter.Update(Me.DBDataSet.myTable) With Best Regards, Mayur
When I try to do that I get a compilation error WindowsApplication2.DBDataSetTableAdapters.myTableTableAdapter' cannot be converted to 'System.Data.OleDb.OleDbDataAdapter'. WindowsApplication2 is my project name chatura -- modified at 0:46 Friday 10th March, 2006
-
When I try to do that I get a compilation error WindowsApplication2.DBDataSetTableAdapters.myTableTableAdapter' cannot be converted to 'System.Data.OleDb.OleDbDataAdapter'. WindowsApplication2 is my project name chatura -- modified at 0:46 Friday 10th March, 2006
Yes… I found the answer I haven’t created the Primary Key. chatura