Home All Groups Group Topic Archive Search About

Concurrency violation: the DeleteCommand affected 0 records vb.net

Author
18 Aug 2006 3:07 PM
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

Author
18 Aug 2006 5:07 PM
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

Show quoteHide quote
"dermot" <dfre***@tommyfrench.co.uk> schreef in bericht
news:1155913636.908227.323510@m73g2000cwd.googlegroups.com...
> 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
>
Author
21 Aug 2006 8:43 AM
dermot
Is there no way to tell the dataset, that child records are
automatically deleted by the stored proc?