472,145 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Update records gives an error after an edit

Does anyone else ever feel like just giving up!!!!!

When i edit a record and then update the database i get an error, although i
can add a new record completely.
The error is : An unhandled exception of type
'System.InvalidOperationException' occurred in system.data.dll
no additional info i can see

Here is the update code i am using
:
' Temporary DataSets to store the inserted or modified row.
Dim pdsInsertedRows, pdsModifiedRows As DataSet
' Set the menu items to indicate that a record is being edited.
Call EditState(cblnNotEditing)

' End editing on the current record.
Me.BindingContext(DsTrailers1, "equiptrailers").EndCurrentEdit()

' Copy the DataSets by getting the added or modified records from the
' original bound DataSet.
pdsInsertedRows = DsTrailers1.GetChanges(DataRowState.Added)
pdsModifiedRows = DsTrailers1.GetChanges(DataRowState.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
odbdaTrailers.Update(pdsInsertedRows)
End If
**********************************************
THE ERROE THORWS HERE ON THE END IF STAEMENT
' Check to see if there is a modified row. If there is update dataset
If Not pdsModifiedRows Is Nothing Then
odbdaTrailers.Update(pdsModifiedRows)
End If
**********************************************

' Synchronize the database
DsTrailers1.AcceptChanges()
Nov 20 '05 #1
3 2273
Is there a reason you want to do the inserts and the updates completely
separately? Why bother getting the update changes and the insert changes
separately, and then updating?

If you put try/catch around the whole thing (which you should anyway, to
catch connection problems, etc), the exception object should have a more
specific message.

"Jeff Brown" <no******@thistime.com> wrote in message
news:aj******************@twister.austin.rr.com...
Does anyone else ever feel like just giving up!!!!!

When i edit a record and then update the database i get an error, although i can add a new record completely.
The error is : An unhandled exception of type
'System.InvalidOperationException' occurred in system.data.dll
no additional info i can see

Here is the update code i am using
:
' Temporary DataSets to store the inserted or modified row.
Dim pdsInsertedRows, pdsModifiedRows As DataSet
' Set the menu items to indicate that a record is being edited.
Call EditState(cblnNotEditing)

' End editing on the current record.
Me.BindingContext(DsTrailers1, "equiptrailers").EndCurrentEdit()

' Copy the DataSets by getting the added or modified records from the
' original bound DataSet.
pdsInsertedRows = DsTrailers1.GetChanges(DataRowState.Added)
pdsModifiedRows = DsTrailers1.GetChanges(DataRowState.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
odbdaTrailers.Update(pdsInsertedRows)
End If
**********************************************
THE ERROE THORWS HERE ON THE END IF STAEMENT
' Check to see if there is a modified row. If there is update dataset
If Not pdsModifiedRows Is Nothing Then
odbdaTrailers.Update(pdsModifiedRows)
End If
**********************************************

' Synchronize the database
DsTrailers1.AcceptChanges()

Nov 20 '05 #2
Will give that a try....

The insert & edit procedures i have working on the local dataset....

I figured that way changes would not be immedialtely commited and hence
prevent faulty edits.
"Marina" <nospam> wrote in message
news:O5**************@tk2msftngp13.phx.gbl...
Is there a reason you want to do the inserts and the updates completely
separately? Why bother getting the update changes and the insert changes
separately, and then updating?

If you put try/catch around the whole thing (which you should anyway, to
catch connection problems, etc), the exception object should have a more
specific message.

"Jeff Brown" <no******@thistime.com> wrote in message
news:aj******************@twister.austin.rr.com...
Does anyone else ever feel like just giving up!!!!!

When i edit a record and then update the database i get an error,
although i
can add a new record completely.
The error is : An unhandled exception of type
'System.InvalidOperationException' occurred in system.data.dll
no additional info i can see

Here is the update code i am using
:
' Temporary DataSets to store the inserted or modified row.
Dim pdsInsertedRows, pdsModifiedRows As DataSet
' Set the menu items to indicate that a record is being edited.
Call EditState(cblnNotEditing)

' End editing on the current record.
Me.BindingContext(DsTrailers1, "equiptrailers").EndCurrentEdit()

' Copy the DataSets by getting the added or modified records from the
' original bound DataSet.
pdsInsertedRows = DsTrailers1.GetChanges(DataRowState.Added)
pdsModifiedRows = DsTrailers1.GetChanges(DataRowState.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
odbdaTrailers.Update(pdsInsertedRows)
End If
**********************************************
THE ERROE THORWS HERE ON THE END IF STAEMENT
' Check to see if there is a modified row. If there is update dataset
If Not pdsModifiedRows Is Nothing Then
odbdaTrailers.Update(pdsModifiedRows)
End If
**********************************************

' Synchronize the database
DsTrailers1.AcceptChanges()


Nov 20 '05 #3
Tried that and i get an empty message box
also tried ex as system.exception and systemexception
and System.InvalidOperationException
with the same results

Try
If Not pdsModifiedRows Is Nothing Then
odbdaTrailers.Update(pdsModifiedRows)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)End Try

"Marina" <nospam> wrote in message
news:O5**************@tk2msftngp13.phx.gbl...
Is there a reason you want to do the inserts and the updates completely
separately? Why bother getting the update changes and the insert changes
separately, and then updating?

If you put try/catch around the whole thing (which you should anyway, to
catch connection problems, etc), the exception object should have a more
specific message.

"Jeff Brown" <no******@thistime.com> wrote in message
news:aj******************@twister.austin.rr.com...
Does anyone else ever feel like just giving up!!!!!

When i edit a record and then update the database i get an error,
although i
can add a new record completely.
The error is : An unhandled exception of type
'System.InvalidOperationException' occurred in system.data.dll
no additional info i can see

Here is the update code i am using
:
' Temporary DataSets to store the inserted or modified row.
Dim pdsInsertedRows, pdsModifiedRows As DataSet
' Set the menu items to indicate that a record is being edited.
Call EditState(cblnNotEditing)

' End editing on the current record.
Me.BindingContext(DsTrailers1, "equiptrailers").EndCurrentEdit()

' Copy the DataSets by getting the added or modified records from the
' original bound DataSet.
pdsInsertedRows = DsTrailers1.GetChanges(DataRowState.Added)
pdsModifiedRows = DsTrailers1.GetChanges(DataRowState.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
odbdaTrailers.Update(pdsInsertedRows)
End If
**********************************************
THE ERROE THORWS HERE ON THE END IF STAEMENT
' Check to see if there is a modified row. If there is update dataset
If Not pdsModifiedRows Is Nothing Then
odbdaTrailers.Update(pdsModifiedRows)
End If
**********************************************

' Synchronize the database
DsTrailers1.AcceptChanges()


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Reney | last post: by
1 post views Thread by mursyidatun ismail | last post: by
5 posts views Thread by PAUL | last post: by
reply views Thread by Metal2You | last post: by
reply views Thread by Access Programming only with macros, no code | last post: by
1 post views Thread by mac89 | last post: by
reply views Thread by leo001 | last post: by

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.