Problem deleting data from SQL table.

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

I am recieving a error when I call dataadapter.update
after deleting a row from the dataset. Does anyone have
any ideas?

The error is: Dynamic SQL generation for the
DeleteCommand is not supported against a SelectCommand
that does not return any key column information.

strSQL = "Select * from Category where CategoryID= " &
CategoryID

Dim DataAdapter As New SqlClient.SqlDataAdapter(strSQL,
strConn)
Dim DataSet As New Data.DataSet
Dim CommandBuilder As New SqlClient.SqlCommandBuilder
(DataAdapter)

DataAdapter.Fill(DataSet, "Category")

DataSet.Tables("Category").Rows(0).Delete()

DataAdapter.Update(DataSet, "Category")
 
Sounds like you need to definte a primary key on your table. That's a good
idea in general anyway.
 
Back
Top