VB Code:
myDataAdapter.UpdateCommand = New OleDbCommand("UPDATE MyTable SET Column1 = ?, Column2 = ? WHERE ID = ?", myConnection)
myDataAdapter.UpdateCommand.Parameters.Add("Column1", OleDbType.VarChar, 50, "Column1")
myDataAdapter.UpdateCommand.Parameters.Add("Column2", OleDbType.Integer, 0, "Column2")
myDataAdapter.UpdateCommand.Parameters.Add("ID", OleDbType.Integer, 50, "ID")
myDataAdapter.UpdateCommand(myDataTable)
Note that the first argument of the Add method is the name of the parameter. It is convention to use column name but it could be anything. The last parameter is the column name and must match the name of the DataColumn in the DataTable from which the data will be retrieved for that parameter. If you use the '?' place-holders your parameters must be added in the same order as they are used in the SQL code. Alternatively you can use named parameters, in which case the order doesn't matter:
VB Code:
myDataAdapter.UpdateCommand = New OleDbCommand("UPDATE MyTable SET Column1 = @Column1, Column2 = @Column2 WHERE ID = @ID", myConnection)
myDataAdapter.UpdateCommand.Parameters.Add("@Column1", OleDbType.VarChar, 50, "Column1")
myDataAdapter.UpdateCommand.Parameters.Add("@Column2", OleDbType.Integer, 0, "Column2")
myDataAdapter.UpdateCommand.Parameters.Add("@ID", OleDbType.Integer, 50, "ID")
myDataAdapter.UpdateCommand(myDataTable)
Note now that the first parameter to each call to the Add method matches the name of the parameter used in the SQL code. The Jet OLEDB provider accepts either format, but that is not the case for all providers.