PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Concurrency Violation

Reply

Concurrency Violation

 
Thread Tools Rate Thread
Old 03-01-2007, 06:34 PM   #1
Dustin Davis
Guest
 
Posts: n/a
Default Concurrency Violation


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

  Reply With Quote
Old 04-01-2007, 02:40 AM   #2
RobinS
Guest
 
Posts: n/a
Default Re: Concurrency Violation

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



  Reply With Quote
Old 04-01-2007, 03:25 PM   #3
Dustin Davis
Guest
 
Posts: n/a
Default Re: Concurrency Violation

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

>
>

  Reply With Quote
Old 04-01-2007, 04:41 PM   #4
RobinS
Guest
 
Posts: n/a
Default Re: Concurrency Violation

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

>>


  Reply With Quote
Old 04-01-2007, 05:00 PM   #5
Dustin Davis
Guest
 
Posts: n/a
Default Re: Concurrency Violation

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
>>>

  Reply With Quote
Old 04-01-2007, 11:02 PM   #6
RobinS
Guest
 
Posts: n/a
Default Re: Concurrency Violation

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
>>>>



  Reply With Quote
Old 05-01-2007, 05:45 AM   #7
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: Concurrency Violation

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


  Reply With Quote
Old 05-01-2007, 05:55 AM   #8
RobinS
Guest
 
Posts: n/a
Default Re: Concurrency Violation

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
>



  Reply With Quote
Old 05-01-2007, 03:50 PM   #9
Dustin Davis
Guest
 
Posts: n/a
Default Re: Concurrency Violation

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

>
>

  Reply With Quote
Old 05-01-2007, 03:52 PM   #10
Dustin Davis
Guest
 
Posts: n/a
Default Re: Concurrency Violation

Crap, I should just start looking for a new job I'm much better with
php! 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
>>

>
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off