469,953 Members | 2,327 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,953 developers. It's quick & easy.

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 2214
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
By using this site, you agree to our Privacy Policy and Terms of Use.