I am using Visual Studio 2010 with VB.Net to connect to an AS400 using the IBM recommended IBM.Data.DB2.Iseries drivers.
I have successfully retrieved data from the AS400/Iseries using SELECT commands from VB.Net.
I have called stored procedures on the AS400/Iseries from VB.Net.
I cannot heowever set up a datadpater to actually update data.
I have populated a dataset from a DataAdapter.Fill and pointed it to a DataGridView but when I change data
in the DataGridView and issue a DataAdapter.Update I get the error, 'Update requires a valid UpdateCommand when passed DataRow collection with modified rows'.
I created the dataAdapter like this behind a form button to read the data and display it in a DataGridView. This works fine and I can see the data on the grid.
I then edit a field in the grid and hit an 'Update' button to call this code:-
When the MyAdatper.Update(MyDataSetA) is executed I get the error,'Update requires a valid UpdateCommand when passed DataRow collection with modified rows'.
My assumption is that I somehow need to set UpdateCommand attached to the DataADapter but I am unclear how to do this. Can anybody help?
Dazed and confused.
Remember.. 'Depression is just anger without enthusiasum'.
I have successfully retrieved data from the AS400/Iseries using SELECT commands from VB.Net.
I have called stored procedures on the AS400/Iseries from VB.Net.
I cannot heowever set up a datadpater to actually update data.
I have populated a dataset from a DataAdapter.Fill and pointed it to a DataGridView but when I change data
in the DataGridView and issue a DataAdapter.Update I get the error, 'Update requires a valid UpdateCommand when passed DataRow collection with modified rows'.
I created the dataAdapter like this behind a form button to read the data and display it in a DataGridView. This works fine and I can see the data on the grid.
Code:
Try
MyConnection6.ConnectionString = "DataSource=MyAS400;"
MyConnection6.Open()
Dim MyCommand6 As New IBM.Data.DB2.iSeries.iDB2Command
MyCommand6.Connection = MyConnection6
MyCommand6.CommandType = CommandType.Text
MyCommand6.CommandText = "SELECT * FROM mylib.myfile"
MyAdapter.SelectCommand = MyCommand6
MyAdapter.Fill(MyDataSetA)
DataGridView1.DataSource = MyDataSetA
DataGridView1.DataMember = MyDataSetA.Tables(0).TableName
MyConnection6.Close()
Catch ex As Exception
MessageBox.Show("Unexpected Program Error: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
End Try
I then edit a field in the grid and hit an 'Update' button to call this code:-
Code:
Try
MyConnection6.ConnectionString = "DataSource=MyAS400;"
MyConnection6.Open()
MyAdapter.Update(MyDataSetA)
MyConnection6.Close()
Catch ex As Exception
MessageBox.Show("Unexpected Program Error: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
When the MyAdatper.Update(MyDataSetA) is executed I get the error,'Update requires a valid UpdateCommand when passed DataRow collection with modified rows'.
My assumption is that I somehow need to set UpdateCommand attached to the DataADapter but I am unclear how to do this. Can anybody help?
Dazed and confused.
Remember.. 'Depression is just anger without enthusiasum'.