Problem deleting data from SQL table.

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")
 
M

Marina

Sounds like you need to definte a primary key on your table. That's a good
idea in general anyway.
 
R

Robert

Thanks,

This was exactly my problem. I though I had set the
primary key, but I didn't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top