473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Concurrency violation: the DeleteCommand affected 0 records vb.net

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

Aug 18 '06 #1
2 4805
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.GetChang es _
(DataRowState.Deleted), _
NorthwindDataSet.Order_DetailsDataTable)
If Not dt Is Nothing Then
Me.Order_DetailsTableAdapter.Update(dt)
End If
Me.OrdersTableAdapter.Update(Me.NorthwindDataSet.O rders)
dt = DirectCast(NorthwindDataSet.Order_Details.GetChang es _
(DataRowState.Modified), _
NorthwindDataSet.Order_DetailsDataTable)
If Not dt Is Nothing Then
Me.Order_DetailsTableAdapter.Update(dt)
End If
dt = DirectCast(NorthwindDataSet.Order_Details.GetChang es _
(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

"dermot" <df*****@tommyfrench.co.ukschreef in bericht
news:11**********************@m73g2000cwd.googlegr oups.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

Aug 18 '06 #2
Is there no way to tell the dataset, that child records are
automatically deleted by the stored proc?

Aug 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Suzanne | last post by:
Hi All I'm having problems getting my data adapter to throw a concurrency exception with an INSERT command. I want to throw a concurrency exception if an attempt is made to enter a row into...
25
by: nick | last post by:
I'm having trouble updating from a datagrid. It's says "Concurrency violation: the UpdateCommand affected 0 records", though I can't see how it's related to "concurrency". I can insert and delete...
1
by: Geraldine Hobley | last post by:
Hello, I have a problem whereby I have a datagrid that is bound to a dataTable. However occassionally when I edit the datagrid I get the following message. Concurrency Violation the update...
1
by: mivey4 | last post by:
Okay, The problem is that I have an Access Database that has the following fields: EmpID - Autonumber (PrimaryKey) AccountID - Text IssueReported - Memo DateOpened ...
2
by: BobAchgill | last post by:
Do you know why this error might be happening? Maybe it is because I have two data adapters open on the same MDB file?? If this is the problem... how can I keep them from disturbing each other?...
5
by: Vayse | last post by:
In my save code, most of items save fine. But sometimes I get a concurrency violation message. "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records." It happens on the...
1
by: Miriam | last post by:
Hello, I got the error "Concurrency violation: the UpdateCommand affected 0 records" while updating some records in the Windows Application. I am using VB.net in VS 2003 and the backend is...
0
by: sherifffruitfly | last post by:
Hi, I'm deleting a bunch of records from my DB, and they actually DO get deleted (as I verify by looking afterwards). But then I get the exception in the subject line. Isn't it weird that all of...
1
by: artteam | last post by:
Hi All, I get an error when I try to delete a record from the datagridview, which says Concurrency violation:the DeleteCommand affected 0 of the expected 1 records . Could someone please...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.