473,802 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Invalid OperationExcept ion' 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(cblnN otEditing)

' End editing on the current record.
Me.BindingConte xt(DsTrailers1, "equiptrailers" ).EndCurrentEdi t()

' Copy the DataSets by getting the added or modified records from the
' original bound DataSet.
pdsInsertedRows = DsTrailers1.Get Changes(DataRow State.Added)
pdsModifiedRows = DsTrailers1.Get Changes(DataRow State.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
odbdaTrailers.U pdate(pdsInsert edRows)
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.U pdate(pdsModifi edRows)
End If
*************** *************** *************** *

' Synchronize the database
DsTrailers1.Acc eptChanges()
Nov 20 '05 #1
3 2392
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******@thist ime.com> wrote in message
news:aj******** **********@twis ter.austin.rr.c om...
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.Invalid OperationExcept ion' 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(cblnN otEditing)

' End editing on the current record.
Me.BindingConte xt(DsTrailers1, "equiptrailers" ).EndCurrentEdi t()

' Copy the DataSets by getting the added or modified records from the
' original bound DataSet.
pdsInsertedRows = DsTrailers1.Get Changes(DataRow State.Added)
pdsModifiedRows = DsTrailers1.Get Changes(DataRow State.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
odbdaTrailers.U pdate(pdsInsert edRows)
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.U pdate(pdsModifi edRows)
End If
*************** *************** *************** *

' Synchronize the database
DsTrailers1.Acc eptChanges()

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******** ******@tk2msftn gp13.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******@thist ime.com> wrote in message
news:aj******** **********@twis ter.austin.rr.c om...
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.Invalid OperationExcept ion' 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(cblnN otEditing)

' End editing on the current record.
Me.BindingConte xt(DsTrailers1, "equiptrailers" ).EndCurrentEdi t()

' Copy the DataSets by getting the added or modified records from the
' original bound DataSet.
pdsInsertedRows = DsTrailers1.Get Changes(DataRow State.Added)
pdsModifiedRows = DsTrailers1.Get Changes(DataRow State.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
odbdaTrailers.U pdate(pdsInsert edRows)
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.U pdate(pdsModifi edRows)
End If
*************** *************** *************** *

' Synchronize the database
DsTrailers1.Acc eptChanges()


Nov 20 '05 #3
Tried that and i get an empty message box
also tried ex as system.exceptio n and systemexception
and System.InvalidO perationExcepti on
with the same results

Try
If Not pdsModifiedRows Is Nothing Then
odbdaTrailers.U pdate(pdsModifi edRows)
End If
Catch ex As Exception
MessageBox.Show (ex.Message, "Error", MessageBoxButto ns.OK,
MessageBoxIcon. Error)End Try

"Marina" <nospam> wrote in message
news:O5******** ******@tk2msftn gp13.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******@thist ime.com> wrote in message
news:aj******** **********@twis ter.austin.rr.c om...
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.Invalid OperationExcept ion' 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(cblnN otEditing)

' End editing on the current record.
Me.BindingConte xt(DsTrailers1, "equiptrailers" ).EndCurrentEdi t()

' Copy the DataSets by getting the added or modified records from the
' original bound DataSet.
pdsInsertedRows = DsTrailers1.Get Changes(DataRow State.Added)
pdsModifiedRows = DsTrailers1.Get Changes(DataRow State.Modified)

' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
odbdaTrailers.U pdate(pdsInsert edRows)
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.U pdate(pdsModifi edRows)
End If
*************** *************** *************** *

' Synchronize the database
DsTrailers1.Acc eptChanges()


Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4103
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
5311
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 are the ones that are of interest. These two columns have "date" type values and shows short time (i.e. 11:39). The program updates the database if I change the values in these columns, or add a new record, or delete a record. But, if one of...
1
2024
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 browsers and click update it gave me this error: Specified argument was out of the range of valid values. Parameter name:
5
3544
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 do the update the changed parentid in the child table fails to change. No error is given its just that the change is not written to the Database. When I step through the records for the child table the one I would expect to be changed has a row...
0
2209
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 .NET 2.0 DataProvider (iAnywhere.Data.AsaClient.dll) into the GAC so it can be used in the ProviderName property of a SQLDataSource and loads properly at run time. The application I'm writing is a bit more complex than the example I'm about to...
9
7755
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 error appears. I will be editing records and then a random one will get the error. A bit of background on my form, this will seem a bit lengthy but here is my code. The form has a navigation list which the user can select a record to view. An...
0
3241
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 - Contact (which has 68,000+ records)
1
2469
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 http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Order Record</title> <meta name="Microsoft Border" content="tlb, default"> </head>
1
2586
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 able to add/delete/edit. Ive worked out how to add and delete entries but Im stuck with the editing part, everytime when you click the Edit button after checking a box of the record you want to edit (and ofcourse changed the text inside the field) it...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10536
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10304
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.