473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 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 2370
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
4
by: Reney | last post by:
I have a very weird problem in updating my datagrid. Please help me to solve it. The datagrid is tied to a dataset table with five columns. Three of them are primary key and the other two columns...
1
by: mursyidatun ismail | last post by:
Dear all, database use: Ms Access. platform: .Net i'm trying to update a record/records in a table called t_doctors by clicking da edit link provided in the database. when i ran through da...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
9
bhcob1
by: bhcob1 | last post by:
Hey guys, 'Update or CancelUpdate without AddNew or Edit' On my database i keep occasionly get this error when i try and edit a field, it is not everytime. It will be working fine and then this...
0
by: Access Programming only with macros, no code | last post by:
ERROR MESSAGE: Could not update; currently locked by another session on this machine. BACKGROUND I have the following objects: Table1 - HO (which has about 51,000+ records) Table2 -...
1
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta...
1
by: mac89 | last post by:
Hi, I was wondering if anyone could help me with this problem. Here is the case, I have a News database which you are able to view here: http://lotrtw.com/news/index_.php And users will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.