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 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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,
|
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...
|
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#:
...
|
by: BStorm |
last post by:
Is it possible to change individual RowState properties from updated to not
updated?
|
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,...
| |
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.
|
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,...
|
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
|
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...
|
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...
|
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. ...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |