473,898 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.acceptchanges and updating to a database

I have a some code which imports information from a text file to a dataset.
Depending op what is being extracted from the text file, the dataset has 5
tables which can be written to. During this accessing I have to delete some
records depending on certain criteria. I initially had some errors because I
wasn't accepting the changes made to the dataset. So using .acceptchanges
fixed the issue. however later on in the program a user may choose "update
changes to database" from the menu, this will only update any changes made to
the dataset after the last .acceptchanges command was issued.

Is there a way of updating the contents of the entire dataset to a database
instead of simply the changes made since the .acceptchanges command was
issued?

Cheers
Niels
Nov 21 '05 #1
2 1830
Niels,

The problem is that the rowstate of your row should be added to get what I
understand that you want.

http://msdn.microsoft.com/library/de...classtopic.asp

However AFAIK is the rowstate is readonly, which would mean that you should
in my opinion copy all tables and than really as new added rows.

I know that there are some problems which can be resolved with acceptchanges
while those problems should not exist.

Can you tell what that problem was?

Cor

"Niels Jensen" <Ni*********@di scussions.micro soft.com>
I have a some code which imports information from a text file to a dataset.
Depending op what is being extracted from the text file, the dataset has 5
tables which can be written to. During this accessing I have to delete
some
records depending on certain criteria. I initially had some errors
because I
wasn't accepting the changes made to the dataset. So using .acceptchanges
fixed the issue. however later on in the program a user may choose "update
changes to database" from the menu, this will only update any changes made
to
the dataset after the last .acceptchanges command was issued.

Is there a way of updating the contents of the entire dataset to a
database
instead of simply the changes made since the .acceptchanges command was
issued?

Cheers
Niels

Nov 21 '05 #2
Hmmm,

Sorry about the lack of responce - I found a way to sort out my problem by
seperating the tables being modified into their own Dataset. This stopped
the error being flagged.

Niels

"Cor Ligthert" wrote:
Niels,

The problem is that the rowstate of your row should be added to get what I
understand that you want.

http://msdn.microsoft.com/library/de...classtopic.asp

However AFAIK is the rowstate is readonly, which would mean that you should
in my opinion copy all tables and than really as new added rows.

I know that there are some problems which can be resolved with acceptchanges
while those problems should not exist.

Can you tell what that problem was?

Cor

"Niels Jensen" <Ni*********@di scussions.micro soft.com>
I have a some code which imports information from a text file to a dataset.
Depending op what is being extracted from the text file, the dataset has 5
tables which can be written to. During this accessing I have to delete
some
records depending on certain criteria. I initially had some errors
because I
wasn't accepting the changes made to the dataset. So using .acceptchanges
fixed the issue. however later on in the program a user may choose "update
changes to database" from the menu, this will only update any changes made
to
the dataset after the last .acceptchanges command was issued.

Is there a way of updating the contents of the entire dataset to a
database
instead of simply the changes made since the .acceptchanges command was
issued?

Cheers
Niels


Nov 21 '05 #3

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

Similar topics

11
16283
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? 1) simply UPDATING the values for all fields in the table, whether or not any particular field has actually changed 2) running a second SELECT statement and comparing the $_POST vars to the returned values, and only UPDATING those that have...
8
13837
by: Allan Bredahl | last post by:
Hi All I have a problem with getting a DataTable to submit changes back to the database when calling AcceptChanges. What I do is simplyfied this : 1) I set up a SqlDataAdapter with SelectCommand, InsertCommand,
0
1518
by: Steve Amey | last post by:
Hi all I have a form with some data bound to it. There is a list on the form that could display any number of records that the user requests. When changes are made to the data I use the GetChanges method to get a temporary DataSet to pass the the Business Object layer, then when the updates have been applied to the database I Merge and then AcceptChanges on the main DataSet.
1
2583
by: Johann Blake | last post by:
I'm not sure that I entirely understand the purpose of the AcceptChanges methon in a DataView. I added a new record to a DataView and noticed that its RowState indicated it as being "Added". If I execute the Update method on an adapter for the table that the DataView is based on, the new record will indeed be written to the database. But if I call AcceptChanges prior to executing the Update method, the RowState for the new record is...
2
351
by: pushpendra vats | last post by:
Hi!!, I have created a dataadapter and datasdet through code .On button i have added two records in dataset and called acceptchanges method. on second button i am inserting the records in database with the helpof update method of dataadapter. But no records are inserted.Now if i remove the dataset.acceptchanges method then it starts adding the records..... what could be the problem....
10
5705
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1) DsStudentCourse1.AcceptChanges() i'm also wondering because w/ out AcceptChanges the data is still save into the database and it is now faster.
3
14817
by: Ryan Liu | last post by:
Hi, In the .NET Framework SDK documentation, I can see DataRow.AcceptChanges method will throw RowNotInTableException exeception. And in DataTable.AcceptChanges(), the documentation does not mention it will throw any exception, but in my code (multi-thread), I see it throw exceptions at two situations: dr = this.currentQuotaUserDt.NewRow();
1
2441
by: Andy B | last post by:
I have the following code: //delete the row in the table that has ID of 1. This line works fine. DataSet.Table.Rows.Find(1).Delete(); //Accept the delete changes to the table. This row returns 'object set to a null reference' exception. Why? DataSet.Tables.Rows.Find(1).AcceptChanges(); Why does this happen if the DataRow.Delete method page on msdn says that you
2
21075
by: Gurny | last post by:
I have a DataSet I am loading via the DataSet.Tables.Add() method. I call the AcceptChanges method on the DataTable first thing. Every thing looks good i.e. RowStates are all Unchanged. I then bind this datatable to an Infragistics Calendarinfo AppointmentsDataBinding object. Everything still going smooth. I run the app and update an appointment. As expected, it updates the datarow and the RowState is changed to Modified. Still going...
0
9993
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
9840
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10948
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
10483
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...
1
8035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5880
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
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4706
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4295
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.