I've written:
Dim strConn As String = "DSN=mysqldsn;" _
& "SERVER=192.168.0.99;" _
& "UID=root;PWD=;OPTION=3; database=date"
Dim objConn As New OdbcConnection(strConn)
objConn.Open()
Dim StrSQL As String = "SELECT * FROM Clienti"
Dim objDA2 = New OdbcDataAdapter(StrSQL, objConn)
Dim ds As New DataSet
objDA2.Fill(ds, "clienti")
ds.Tables("clienti").Rows(0)(2) = "dsfsf"
objDA2.Update(ds, "clienti")
I got rhe error:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows
I tryed to add an update command like this
objDA2.UpdateCommand = New OdbcCommand
objDA2.UpdateCommand.Connection = objConn
objDA2.UpdateCommand.CommandText = "UPDATE Clienti SET ID=@ID, Denumire = @Denumire, Adresa = @Adresa, Telefon = @Telefon WHERE (ID = @Original_ID) AND (Adresa = @Original_Adresa OR @Original_Adresa IS NULL AND Adresa IS NULL) AND (Denumire = @Original_Denumire OR @Original_Denumire IS NULL AND Denumire IS NULL) AND (Telefon = @Original_Telefon OR @Original_Telefon IS NULL AND Telefon IS NULL)"
objDA2.UpdateCommand.Parameters.Add(New OdbcParameter("@ID", Microsoft.Data.Odbc.OdbcType.BigInt, 8, "ID"))
objDA2.UpdateCommand.Parameters.Add(New OdbcParameter("@Denumire", Microsoft.Data.Odbc.OdbcType.Text, 50, "Denumire"))
objDA2.UpdateCommand.Parameters.Add(New OdbcParameter("@Adresa", Microsoft.Data.Odbc.OdbcType.Text, 50, "Adresa"))
objDA2.UpdateCommand.Parameters.Add(New OdbcParameter("@Telefon", Microsoft.Data.Odbc.OdbcType.Text, 50, "Telefon"))
objDA2.UpdateCommand.Parameters.Add(New OdbcParameter("@Original_ID", Microsoft.Data.Odbc.OdbcType.BigInt, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
objDA2.UpdateCommand.Parameters.Add(New OdbcParameter("@Original_Denumire", Microsoft.Data.Odbc.OdbcType.Text, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Denumirea", System.Data.DataRowVersion.Original, Nothing))
objDA2.UpdateCommand.Parameters.Add(New OdbcParameter("@Original_Adresa", Microsoft.Data.Odbc.OdbcType.Text, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Adresa", System.Data.DataRowVersion.Original, Nothing))
objDA2.UpdateCommand.Parameters.Add(New OdbcParameter("@Original_Telefon", Microsoft.Data.Odbc.OdbcType.Text, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Telefon", System.Data.DataRowVersion.Original, Nothing))
I got the error message
Concurrency violation: the UpdateCommand affected 0 records.
Please help me.