473,386 Members | 1,652 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,386 software developers and data experts.

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 2529
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
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...
0
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...
2
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...
6
by: BStorm | last post by:
Is it possible to change individual RowState properties from updated to not updated?
4
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...
10
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)...
9
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...
4
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.