Concurrency violation: the DeleteCommand affected 0 records vb.net

D

dermot

Hi,
I have a vb.net application accessing a SQL Server 2005 Database.
It applys changes to the database using stored procedures.

Updates and Inserts are working fine.

Parent Table = Customers, Child Table = Orders

However if I delete a record from the parent table, customers I get a
concurrency error (fired when I try to update the child table). I
think the reason is in SQL Server 2005 the deletes automatically
cascade, but the VB application is trying to delete that customers
orders as well.

Anyway to stop that. I have a strongly typed dataset.

Regards,
Dermot
 
C

Cor Ligthert [MVP]

Dermot,

You become not happy when you see this.
This is with a WindowForms Net 2.0 dataset.

\\\
Dim dt As NorthwindDataSet.Order_DetailsDataTable = _
DirectCast(NorthwindDataSet.Order_Details.GetChanges _
(DataRowState.Deleted), _
NorthwindDataSet.Order_DetailsDataTable)
If Not dt Is Nothing Then
Me.Order_DetailsTableAdapter.Update(dt)
End If
Me.OrdersTableAdapter.Update(Me.NorthwindDataSet.Orders)
dt = DirectCast(NorthwindDataSet.Order_Details.GetChanges _
(DataRowState.Modified), _
NorthwindDataSet.Order_DetailsDataTable)
If Not dt Is Nothing Then
Me.Order_DetailsTableAdapter.Update(dt)
End If
dt = DirectCast(NorthwindDataSet.Order_Details.GetChanges _
(DataRowState.Added), NorthwindDataSet.Order_DetailsDataTable)
If Not dt Is Nothing Then
Me.Order_DetailsTableAdapter.Update(dt)
End If
Me.NorthwindDataSet.Order_Details.AcceptChanges()
///

But I hope that it helps something,

Cor
 
D

dermot

Is there no way to tell the dataset, that child records are
automatically deleted by the stored proc?
 

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