473,545 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't understand the purpose of AcceptChanges on a DataView

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 changed to "Unchanged" and the new
record is not stored in the database when the Update method is
executed.

I don't get it. The .NET documentation clearly states the following:

"Calling AcceptChanges on the DataSet, DataTable, or DataRow will cause
all Original values for a DataRow to be overwritten with the Current
values for the DataRow"

and...

"After verifying the accuracy of changes made to data in a DataTable,
you can accept the changes using the AcceptChanges method of the
DataRow, DataTable, or DataSet, which will set the Current row values
to be the Original values and will set the RowState property to
Unchanged"

This is exactly what it is doing but what's the logic for not allowing
this newly added record to be stored in the database. Just because the
RowState now indicates "Unchanged" , this should mean that the new
record should not be stored?? What then is the point of AcceptChanges
if you can't store the changes you've accepted?

Thanks for your response.
Johann Blake

Nov 17 '05 #1
1 2551
The AcceptChanges method of DataView should only be used when you "accept the
changes" and you don't wanna update the database or in other word, only
update the presentation layer. (which means AcceptChanges method is a very
easy way to set the RowState of each DataRow object to unchange, so you don't
have to set the RowState in each DataRow object)

when the update method of the DataAdapter is called, it will called the
AcceptChanges method after it update the database.

"Johann Blake" wrote:
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 changed to "Unchanged" and the new
record is not stored in the database when the Update method is
executed.

I don't get it. The .NET documentation clearly states the following:

"Calling AcceptChanges on the DataSet, DataTable, or DataRow will cause
all Original values for a DataRow to be overwritten with the Current
values for the DataRow"

and...

"After verifying the accuracy of changes made to data in a DataTable,
you can accept the changes using the AcceptChanges method of the
DataRow, DataTable, or DataSet, which will set the Current row values
to be the Original values and will set the RowState property to
Unchanged"
The documentation clearly states that after AcceptChanges method is called
it will ONLY change the RowState to "Unchanged" WITHOUT update the database.

This is exactly what it is doing but what's the logic for not allowing
this newly added record to be stored in the database. Just because the
RowState now indicates "Unchanged" , this should mean that the new
record should not be stored?? What then is the point of AcceptChanges
if you can't store the changes you've accepted?

Thanks for your response.
Johann Blake


Hope it helps
Ivan Wong
Nov 17 '05 #2

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

Similar topics

8
13777
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
1491
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...
2
1631
by: Torben Madsen | last post by:
Hello, I'm trying to save the changes back to the database, but it doesn't work -could anybody help me? I'm using a DataSet and the wierd thing is that I can save the changes in the memory but not in the database :-/ I have tried to duplicate an example I found on msdn -but with no luck. The sourcecode is in C#: ...
6
13476
by: BStorm | last post by:
Is it possible to change individual RowState properties from updated to not updated?
4
2002
by: CaptRR | last post by:
I think this is the right group to post to, so here goes. My problem is this, I cannot update the datarow to save my life. Been on this for 2 days now, and still am no closer to figuring it out than I was before. I'm basicly taking date from some text boxes, trying to put them into a datarow and using that datarow to update the database,...
10
5634
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.
9
1213
by: Marc R. | last post by:
Happy new year everyone, Back from vacation, and here's a new Chalenge for "moi". I got 2 Dataview. 1 for DVsupplierSearch that is bind to a grid 1 for DVSupplierDetails, that is bind to several TextBox for Edits Both are views from SupplierTable in same Dataset. Went I edit the Textboxes, the grids takes the edited information correctly,...
4
12417
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
1
2418
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...
0
7457
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...
0
7651
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. ...
0
7802
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...
0
5962
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...
1
5320
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...
0
4941
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3438
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1869
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
1
1010
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.