Home All Groups Group Topic Archive Search About

InRowChangingEventException from DataSet.AcceptChanges

Author
17 Nov 2005 12:21 AM
Michael Freidgeim
One of my customers received a few InRowChangingEventExceptions :
System.Data.InRowChangingEventException: Cannot call EndEdit inside an
OnRowChanging event.
   at System.Data.DataRow.EndEdit()
   at System.Data.DataTable.AcceptChanges()
   at System.Data.DataSet.AcceptChanges()
This is not reproducible  error - it is reported only one day for this
customer and doesn't happen for other customers.
But it seems that once happnned, the application wasn't able to recover
from the error until the dataset was destroyed from memory.
The application loads the dataset once and then  in a loop a few times
updates/adds new records to the Dataset and saves them to the database.
The excerpt from the code is the following.

        Try
            Dim con1 As New SqlConnection(m_connString)
            Dim sSQL As String
            Dim commandBuilder As SqlCommandBuilder
            dsChanges = m_dsKeyword.GetChanges
            If Not (dsChanges Is Nothing) Then
                sSQL = "select * from Keyword"
                da = New SqlDataAdapter(sSQL, con1)
                commandBuilder = New SqlCommandBuilder(da)
                da.ContinueUpdateOnError = True
                da.Update(dsChanges, "Keyword")
                m_dsKeyword.AcceptChanges() 'm_dsKeyword gas only one
table "Keyword"
            End If
        Catch exc As Exception
            Try 'to clear current data to isolate the problem
                m_dsKeyword.AcceptChanges()
            Catch ' ignore  errors during cleanup
            End Try
        End Try


I know that the customer has some intermittent problems with SQL Server
(see
http://groups.google.com.au/group/microsoft.public.sqlserver.server/msg/038e2dfbbebffa48?hl=en&)
but no SQL errors were reported on the time of
InRowChangingEventExceptions

I will appreciate any suggestions why these
InRowChangingEventExceptions were raised and how is it possible to
recover from the error without re-populating dataset.

AddThis Social Bookmark Button