
Deleting entry from table using ODBC - please help
I am trying to delete an entry from a table using ODBC in VB.NET. I can read
data into my dataset with no problem but I can't make a delete work.
Below is what I'm doing for a read (I've left out the information on connecting
to the data source, etc.). It works fine. I tried to do a .Delete on the
dataset row that is returned, to set the .DeleteCommand on the daODBC variable,
and then do a .Update on the daODBC variable. This returned a system error.
If someone could help me understand what needs to be done to delete the one row
that is returned (in the database, not the datatable variable), I would really
appreciate it. Thank you.
Dim daODBC As New OdbcDataAdapter()
Dim dtItems As DataTable
Dim mcnData As OdbcConnection
Dim ocODBC As New OdbcCommand()
Dim sSQLCommand As String
mcnData = New OdbcConnection()
mcnData.ConnectionString = sODBCConnectionString
mcnData.Open()
sSQLCommand = "SELECT Field1, Field2 FROM MyTable WHERE Field1 = 5"
ocODBC.Connection = mcnData
ocODBC.CommandText = sSQLCommand
daODBC.SelectCommand = ocODBC
dtItems = New DataTable()
daODBC.Fill(dtItems)
If (dtItems.Rows.Count > 0) Then
End If