Update requires a valid InsertCommand when passed DataRow collection with new rows.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi everybody, im trying to add items to my database and this error comes out .. Update requires a valid InsertCommand when passed DataRow collection with new rows.
Thanks for the help ..

<pre class="prettyprint Private Sub save_client()
Dim cb As New OleDb.OleDbCommandBuilder(da)

Call connection()
sql = "select * from TBLCLIENT"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "TBLCLIENT")
cmd = New OleDb.OleDbCommand(sql, con)


Dim dsNewRow As DataRow
dsNewRow = ds.Tables("TBLCLIENT").NewRow
dsNewRow.Item("reserv_num") = RandomNumber
dsNewRow.Item("NAME_CUSTOMER") = txtFirstName.Text + " " + txtMI.Text + " " + txtLastName.Text
dsNewRow.Item("id_details") = TextBox1.Text

ds.Tables("TBLCLIENT").Rows.Add(dsNewRow)
da.Update(ds, "TBLCLIENT")


con.Close()
End Sub[/code]
<br/>


View the full article
 
Back
Top