PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Concurrency Violation
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Concurrency Violation
![]() |
Concurrency Violation |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
When the following subroutine executes I get a concurrency violation.
I'm not sure why. Can someone help provide a clue for me? (drvZones is a DataRowView) > Private Sub SplitMultipageTIFsWithThisZoneToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplitMultipageTIFsWithThisZoneToolStripMenuItem.Click > Me.ZonesBindingSource.EndEdit() > For i As Integer = 0 To DsZones.Tables(0).Rows.Count - 1 > Me.drvZone = Me.ZonesBindingSource.Item(i) > If i = Me.lstZones.SelectedIndex Then > drvZone.Item("split_zone") = 1 > Else > drvZone.Item("split_zone") = 0 > End If > Next > > Try > Me.ZonesBindingSource.EndEdit() > Me.ZonesTableAdapter.Update(Me.DsZones) > Catch ex As Exception > MsgBox(ex.Message, MsgBoxStyle.Critical) > End Try > > Me.lstZones.Refresh() > End Sub |
|
|
|
#2 |
|
Guest
Posts: n/a
|
According to one book that I have, when using a SqlDataAdapter, it
throws a DBConcurrencyException if the UpdateQuery doesn't modify any rows. So maybe your tableAdapter.Update isn't working, and is giving you the exception to tell you that. That would happen when someone else has updated the row after you displayed it and before you updated yours, or if somehow your data row is marked as an Update, and it can't find the record to be updated. That's my best guess. I think this is related to your other problem. Robin S. ---------------------------------------- "Dustin Davis" <dustin@davisvillage.com> wrote in message news:ujlKdV2LHHA.5016@TK2MSFTNGP04.phx.gbl... > When the following subroutine executes I get a concurrency violation. > I'm not sure why. Can someone help provide a clue for me? > > (drvZones is a DataRowView) > >> Private Sub >> SplitMultipageTIFsWithThisZoneToolStripMenuItem_Click(ByVal sender As >> System.Object, ByVal e As System.EventArgs) Handles >> SplitMultipageTIFsWithThisZoneToolStripMenuItem.Click >> Me.ZonesBindingSource.EndEdit() >> For i As Integer = 0 To DsZones.Tables(0).Rows.Count - 1 >> Me.drvZone = Me.ZonesBindingSource.Item(i) >> If i = Me.lstZones.SelectedIndex Then >> drvZone.Item("split_zone") = 1 >> Else >> drvZone.Item("split_zone") = 0 >> End If >> Next >> >> Try >> Me.ZonesBindingSource.EndEdit() >> Me.ZonesTableAdapter.Update(Me.DsZones) >> Catch ex As Exception >> MsgBox(ex.Message, MsgBoxStyle.Critical) >> End Try >> >> Me.lstZones.Refresh() >> End Sub |
|
|
|
#3 |
|
Guest
Posts: n/a
|
That may have been it - I was updating records that were not necessarily
changing. I did some more digging on the Internet and found out how to turn off optimistic concurrency and that seemed to solve the problem. Thanks. RobinS wrote: > According to one book that I have, when using a SqlDataAdapter, it > throws a DBConcurrencyException if the UpdateQuery doesn't modify any > rows. So maybe your tableAdapter.Update isn't working, and is giving you > the exception to tell you that. > > That would happen when someone else has updated the row after you > displayed it and before you updated yours, or if somehow your data row > is marked as an Update, and it can't find the record to be updated. > > That's my best guess. I think this is related to your other problem. > > Robin S. > ---------------------------------------- > "Dustin Davis" <dustin@davisvillage.com> wrote in message > news:ujlKdV2LHHA.5016@TK2MSFTNGP04.phx.gbl... >> When the following subroutine executes I get a concurrency violation. >> I'm not sure why. Can someone help provide a clue for me? >> >> (drvZones is a DataRowView) >> >>> Private Sub >>> SplitMultipageTIFsWithThisZoneToolStripMenuItem_Click(ByVal sender As >>> System.Object, ByVal e As System.EventArgs) Handles >>> SplitMultipageTIFsWithThisZoneToolStripMenuItem.Click >>> Me.ZonesBindingSource.EndEdit() >>> For i As Integer = 0 To DsZones.Tables(0).Rows.Count - 1 >>> Me.drvZone = Me.ZonesBindingSource.Item(i) >>> If i = Me.lstZones.SelectedIndex Then >>> drvZone.Item("split_zone") = 1 >>> Else >>> drvZone.Item("split_zone") = 0 >>> End If >>> Next >>> >>> Try >>> Me.ZonesBindingSource.EndEdit() >>> Me.ZonesTableAdapter.Update(Me.DsZones) >>> Catch ex As Exception >>> MsgBox(ex.Message, MsgBoxStyle.Critical) >>> End Try >>> >>> Me.lstZones.Refresh() >>> End Sub > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
That means that your code will not be able to discern whether the
update was successful or not. Just FYI. Robin S. ------------------------ "Dustin Davis" <dustin@davisvillage.com> wrote in message news:%23iPrfQBMHHA.3872@TK2MSFTNGP06.phx.gbl... > That may have been it - I was updating records that were not > necessarily changing. I did some more digging on the Internet and > found out how to turn off optimistic concurrency and that seemed to > solve the problem. > > Thanks. > > RobinS wrote: >> According to one book that I have, when using a SqlDataAdapter, it >> throws a DBConcurrencyException if the UpdateQuery doesn't modify any >> rows. So maybe your tableAdapter.Update isn't working, and is giving >> you the exception to tell you that. >> >> That would happen when someone else has updated the row after you >> displayed it and before you updated yours, or if somehow your data >> row is marked as an Update, and it can't find the record to be >> updated. >> >> That's my best guess. I think this is related to your other problem. >> >> Robin S. >> ---------------------------------------- >> "Dustin Davis" <dustin@davisvillage.com> wrote in message >> news:ujlKdV2LHHA.5016@TK2MSFTNGP04.phx.gbl... >>> When the following subroutine executes I get a concurrency >>> violation. I'm not sure why. Can someone help provide a clue for me? >>> >>> (drvZones is a DataRowView) >>> >>>> Private Sub >>>> SplitMultipageTIFsWithThisZoneToolStripMenuItem_Click(ByVal sender >>>> As System.Object, ByVal e As System.EventArgs) Handles >>>> SplitMultipageTIFsWithThisZoneToolStripMenuItem.Click >>>> Me.ZonesBindingSource.EndEdit() >>>> For i As Integer = 0 To DsZones.Tables(0).Rows.Count - 1 >>>> Me.drvZone = Me.ZonesBindingSource.Item(i) >>>> If i = Me.lstZones.SelectedIndex Then >>>> drvZone.Item("split_zone") = 1 >>>> Else >>>> drvZone.Item("split_zone") = 0 >>>> End If >>>> Next >>>> >>>> Try >>>> Me.ZonesBindingSource.EndEdit() >>>> Me.ZonesTableAdapter.Update(Me.DsZones) >>>> Catch ex As Exception >>>> MsgBox(ex.Message, MsgBoxStyle.Critical) >>>> End Try >>>> >>>> Me.lstZones.Refresh() >>>> End Sub >> |
|
|
|
#5 |
|
Guest
Posts: n/a
|
It's a single user application, so only one user will ever access it.
Kerry Moorman wrote: > Dustin, > > Just out of curiosity, how are you handling concurrency issues if you turned > off optimistic concurrency? > > Kerry Moorman > > > "Dustin Davis" wrote: > >> That may have been it - I was updating records that were not necessarily >> changing. I did some more digging on the Internet and found out how to >> turn off optimistic concurrency and that seemed to solve the problem. >> >> Thanks. >> >> RobinS wrote: >>> According to one book that I have, when using a SqlDataAdapter, it >>> throws a DBConcurrencyException if the UpdateQuery doesn't modify any >>> rows. So maybe your tableAdapter.Update isn't working, and is giving you >>> the exception to tell you that. >>> >>> That would happen when someone else has updated the row after you >>> displayed it and before you updated yours, or if somehow your data row >>> is marked as an Update, and it can't find the record to be updated. >>> >>> That's my best guess. I think this is related to your other problem. >>> >>> Robin S. >>> ---------------------------------------- >>> "Dustin Davis" <dustin@davisvillage.com> wrote in message >>> news:ujlKdV2LHHA.5016@TK2MSFTNGP04.phx.gbl... >>>> When the following subroutine executes I get a concurrency violation. >>>> I'm not sure why. Can someone help provide a clue for me? >>>> >>>> (drvZones is a DataRowView) >>>> >>>>> Private Sub >>>>> SplitMultipageTIFsWithThisZoneToolStripMenuItem_Click(ByVal sender As >>>>> System.Object, ByVal e As System.EventArgs) Handles >>>>> SplitMultipageTIFsWithThisZoneToolStripMenuItem.Click >>>>> Me.ZonesBindingSource.EndEdit() >>>>> For i As Integer = 0 To DsZones.Tables(0).Rows.Count - 1 >>>>> Me.drvZone = Me.ZonesBindingSource.Item(i) >>>>> If i = Me.lstZones.SelectedIndex Then >>>>> drvZone.Item("split_zone") = 1 >>>>> Else >>>>> drvZone.Item("split_zone") = 0 >>>>> End If >>>>> Next >>>>> >>>>> Try >>>>> Me.ZonesBindingSource.EndEdit() >>>>> Me.ZonesTableAdapter.Update(Me.DsZones) >>>>> Catch ex As Exception >>>>> MsgBox(ex.Message, MsgBoxStyle.Critical) >>>>> End Try >>>>> >>>>> Me.lstZones.Refresh() >>>>> End Sub >>> |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Which brings up the question - how are you getting concurrency problems
in that case? Robin S. ------------------- "Dustin Davis" <dustin@davisvillage.com> wrote in message news:uooVnFCMHHA.320@TK2MSFTNGP06.phx.gbl... > It's a single user application, so only one user will ever access it. > > Kerry Moorman wrote: >> Dustin, >> >> Just out of curiosity, how are you handling concurrency issues if you >> turned off optimistic concurrency? >> >> Kerry Moorman >> >> >> "Dustin Davis" wrote: >> >>> That may have been it - I was updating records that were not >>> necessarily changing. I did some more digging on the Internet and >>> found out how to turn off optimistic concurrency and that seemed to >>> solve the problem. >>> >>> Thanks. >>> >>> RobinS wrote: >>>> According to one book that I have, when using a SqlDataAdapter, it >>>> throws a DBConcurrencyException if the UpdateQuery doesn't modify >>>> any rows. So maybe your tableAdapter.Update isn't working, and is >>>> giving you the exception to tell you that. >>>> >>>> That would happen when someone else has updated the row after you >>>> displayed it and before you updated yours, or if somehow your data >>>> row is marked as an Update, and it can't find the record to be >>>> updated. >>>> >>>> That's my best guess. I think this is related to your other >>>> problem. >>>> >>>> Robin S. >>>> ---------------------------------------- >>>> "Dustin Davis" <dustin@davisvillage.com> wrote in message >>>> news:ujlKdV2LHHA.5016@TK2MSFTNGP04.phx.gbl... >>>>> When the following subroutine executes I get a concurrency >>>>> violation. I'm not sure why. Can someone help provide a clue for >>>>> me? >>>>> >>>>> (drvZones is a DataRowView) >>>>> >>>>>> Private Sub >>>>>> SplitMultipageTIFsWithThisZoneToolStripMenuItem_Click(ByVal >>>>>> sender As System.Object, ByVal e As System.EventArgs) Handles >>>>>> SplitMultipageTIFsWithThisZoneToolStripMenuItem.Click >>>>>> Me.ZonesBindingSource.EndEdit() >>>>>> For i As Integer = 0 To DsZones.Tables(0).Rows.Count - 1 >>>>>> Me.drvZone = Me.ZonesBindingSource.Item(i) >>>>>> If i = Me.lstZones.SelectedIndex Then >>>>>> drvZone.Item("split_zone") = 1 >>>>>> Else >>>>>> drvZone.Item("split_zone") = 0 >>>>>> End If >>>>>> Next >>>>>> >>>>>> Try >>>>>> Me.ZonesBindingSource.EndEdit() >>>>>> Me.ZonesTableAdapter.Update(Me.DsZones) >>>>>> Catch ex As Exception >>>>>> MsgBox(ex.Message, MsgBoxStyle.Critical) >>>>>> End Try >>>>>> >>>>>> Me.lstZones.Refresh() >>>>>> End Sub >>>> |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Dustin,
The thing from that creates the most unwanted concurrency errors is the autoidentifier. In my opinion is that not made for datatables and things like that, but more for the less advanced use in the past. If you don't clean your datasets after an update with an autoident, you will have more rows than there really exist. Can this be the problem? Cor |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Assuming it's the same routine he asked about in an earlier post,
he has bigger problems than that. He was kind of changing the dataset in one place, and the bindingsource in another, and it was kind of mixed up. I spent a considerable amount of time looking at it and marked it up and send it back to him; hopefully that will fix this problem as well. Robin S. ---------------------------------- "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message news:uq3AmxIMHHA.3552@TK2MSFTNGP03.phx.gbl... > Dustin, > > The thing from that creates the most unwanted concurrency errors is > the autoidentifier. > > In my opinion is that not made for datatables and things like that, > but more for the less advanced use in the past. > > If you don't clean your datasets after an update with an autoident, > you will have more rows than there really exist. Can this be the > problem? > > Cor > |
|
|
|
#9 |
|
Guest
Posts: n/a
|
That's what I can't figure out and why I'm posting here...
![]() Oddly, I thought this fixed the problem, but I got another concurrency problem while testing, even with optimistic concurrency turned off :baffled: RobinS wrote: > Which brings up the question - how are you getting concurrency problems > in that case? > Robin S. > ------------------- > "Dustin Davis" <dustin@davisvillage.com> wrote in message > news:uooVnFCMHHA.320@TK2MSFTNGP06.phx.gbl... >> It's a single user application, so only one user will ever access it. >> >> Kerry Moorman wrote: >>> Dustin, >>> >>> Just out of curiosity, how are you handling concurrency issues if you >>> turned off optimistic concurrency? >>> >>> Kerry Moorman >>> >>> >>> "Dustin Davis" wrote: >>> >>>> That may have been it - I was updating records that were not >>>> necessarily changing. I did some more digging on the Internet and >>>> found out how to turn off optimistic concurrency and that seemed to >>>> solve the problem. >>>> >>>> Thanks. >>>> >>>> RobinS wrote: >>>>> According to one book that I have, when using a SqlDataAdapter, it >>>>> throws a DBConcurrencyException if the UpdateQuery doesn't modify >>>>> any rows. So maybe your tableAdapter.Update isn't working, and is >>>>> giving you the exception to tell you that. >>>>> >>>>> That would happen when someone else has updated the row after you >>>>> displayed it and before you updated yours, or if somehow your data >>>>> row is marked as an Update, and it can't find the record to be >>>>> updated. >>>>> >>>>> That's my best guess. I think this is related to your other >>>>> problem. >>>>> >>>>> Robin S. >>>>> ---------------------------------------- >>>>> "Dustin Davis" <dustin@davisvillage.com> wrote in message >>>>> news:ujlKdV2LHHA.5016@TK2MSFTNGP04.phx.gbl... >>>>>> When the following subroutine executes I get a concurrency >>>>>> violation. I'm not sure why. Can someone help provide a clue for >>>>>> me? >>>>>> >>>>>> (drvZones is a DataRowView) >>>>>> >>>>>>> Private Sub >>>>>>> SplitMultipageTIFsWithThisZoneToolStripMenuItem_Click(ByVal >>>>>>> sender As System.Object, ByVal e As System.EventArgs) Handles >>>>>>> SplitMultipageTIFsWithThisZoneToolStripMenuItem.Click >>>>>>> Me.ZonesBindingSource.EndEdit() >>>>>>> For i As Integer = 0 To DsZones.Tables(0).Rows.Count - 1 >>>>>>> Me.drvZone = Me.ZonesBindingSource.Item(i) >>>>>>> If i = Me.lstZones.SelectedIndex Then >>>>>>> drvZone.Item("split_zone") = 1 >>>>>>> Else >>>>>>> drvZone.Item("split_zone") = 0 >>>>>>> End If >>>>>>> Next >>>>>>> >>>>>>> Try >>>>>>> Me.ZonesBindingSource.EndEdit() >>>>>>> Me.ZonesTableAdapter.Update(Me.DsZones) >>>>>>> Catch ex As Exception >>>>>>> MsgBox(ex.Message, MsgBoxStyle.Critical) >>>>>>> End Try >>>>>>> >>>>>>> Me.lstZones.Refresh() >>>>>>> End Sub > > |
|
|
|
#10 |
|
Guest
Posts: n/a
|
Crap, I should just start looking for a new job
I'm much better withphp! hehe RobinS wrote: > Assuming it's the same routine he asked about in an earlier post, > he has bigger problems than that. He was kind of changing > the dataset in one place, and the bindingsource in another, > and it was kind of mixed up. I spent a considerable amount of > time looking at it and marked it up and send it back to him; > hopefully that will fix this problem as well. > > Robin S. > ---------------------------------- > > "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message > news:uq3AmxIMHHA.3552@TK2MSFTNGP03.phx.gbl... >> Dustin, >> >> The thing from that creates the most unwanted concurrency errors is >> the autoidentifier. >> >> In my opinion is that not made for datatables and things like that, >> but more for the less advanced use in the past. >> >> If you don't clean your datasets after an update with an autoident, >> you will have more rows than there really exist. Can this be the >> problem? >> >> Cor >> > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 


I'm much better with
