Delete rows using a dataset and DAAB

J

jacob4408

I can get updates and inserts to work but not deletes. This code
yields a DBConcurrencyException 0 records affected even in situations
where the delete does take place and removes several records. Can
anyone point out what I'm doing wrong? Thanks.

Dim dsUpdate As New DataSet
'retrieve specific rows
dsUpdate = SqlHelper.ExecuteDataset(CommandType.Text,
"select * from learning.dbo.datasettest where Text1 = 'a'")

'establish table name because DAAB doesn't do this
dsUpdate.Tables(0).TableName = "learning.dbo.datasettest"

''delete existing records
Dim intCount As Integer = dsUpdate.Tables(0).Rows.Count -
1
For intLoop As Integer = intCount To 0 Step -1
If CStr(dsUpdate.Tables(0).Rows(intLoop).Item(0)) =
"a" Then
dsUpdate.Tables(0).Rows(0).Delete
End If
Next

'update new dataset to the db
SqlHelper.UpdateDataset(insertCommand, deleteCommand,
updateCommand, dsUpdate, "learning.dbo.datasettest")
 

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