473,800 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataAdapter.Acc eptChangesDurin gUpdate not working


I have set DataAdapter.Acc eptChangesDurin gUpdate = true;

However, I find that I still need to call AcceptChanges on the associated
DataTable,

DataTable.Accep tChanges();

Has anyone encountered that? Am I not setting this field properly?

The following are some of the snippets of the codes which may help explain
what I was doing,
//Setting DataAdapter.Acc eptChangesDurin gUpdate
{
....

jobListDataAdap ter = new
System.Data.Ole Db.OleDbDataAda pter(commandStr ing, oOleDbConn);

oOleDbCommandBu ilder = new
System.Data.Ole Db.OleDbCommand Builder(jobList DataAdapter);

jobListDataTabl e = new System.Data.Dat aTable("Job List
Access DataTable");
jobListDataAdap ter.AcceptChang esDuringFill = true;
jobListDataAdap ter.AcceptChang esDuringUpdate = true;

jobListDataAdap ter.Fill(jobLis tDataTable);
....
}

Thanks,

--
George
Jun 16 '06 #1
5 5047
You are only getting data into the table in this example. You are not
updating the database, so that property would not be relevant.

"George" <wa**@nospam.no spam> wrote in message
news:E0******** *************** ***********@mic rosoft.com...

I have set DataAdapter.Acc eptChangesDurin gUpdate = true;

However, I find that I still need to call AcceptChanges on the associated
DataTable,

DataTable.Accep tChanges();

Has anyone encountered that? Am I not setting this field properly?

The following are some of the snippets of the codes which may help explain
what I was doing,
//Setting DataAdapter.Acc eptChangesDurin gUpdate
{
...

jobListDataAdap ter = new
System.Data.Ole Db.OleDbDataAda pter(commandStr ing, oOleDbConn);

oOleDbCommandBu ilder = new
System.Data.Ole Db.OleDbCommand Builder(jobList DataAdapter);

jobListDataTabl e = new System.Data.Dat aTable("Job List
Access DataTable");
jobListDataAdap ter.AcceptChang esDuringFill = true;
jobListDataAdap ter.AcceptChang esDuringUpdate = true;

jobListDataAdap ter.Fill(jobLis tDataTable);
...
}

Thanks,

--
George

Jun 16 '06 #2
The snippet only demonstrate how I setup AcceptChangesDu ringUpdate.

Eventually, at some other location I would have call

{
....
oChangeDataTabl e = this.jobListDat aTable.GetChang es();
if (oChangeDataTab le != null)
{
this.JobListDat aAdapter.Update (oChangeDataTab le);

foreach (System.Data.Da taRow oDataRow in
oChangeDataTabl e.Rows)
{
if (oDataRow[JobDataGridView ColumnId] ==
System.DBNull.V alue)
{
this.jobListDat aTable.Clear();

this.jobListDat aAdapter.Fill(t his.jobListData Table);
break;
}
}

jobListDataTabl e.AcceptChanges ();

....
}

After Update(), the RowState of changed rows seem to be updated to
"unchanged" from "Added", "Deleted".. . and what not.

However, without specifically calling DataTable.Accep tChanges(), the next
call to DataTable.GetCh anges() still returns a table of changed rows.

Any ideas?

--
George
"Marina Levit [MVP]" wrote:
You are only getting data into the table in this example. You are not
updating the database, so that property would not be relevant.

"George" <wa**@nospam.no spam> wrote in message
news:E0******** *************** ***********@mic rosoft.com...

I have set DataAdapter.Acc eptChangesDurin gUpdate = true;

However, I find that I still need to call AcceptChanges on the associated
DataTable,

DataTable.Accep tChanges();

Has anyone encountered that? Am I not setting this field properly?

The following are some of the snippets of the codes which may help explain
what I was doing,
//Setting DataAdapter.Acc eptChangesDurin gUpdate
{
...

jobListDataAdap ter = new
System.Data.Ole Db.OleDbDataAda pter(commandStr ing, oOleDbConn);

oOleDbCommandBu ilder = new
System.Data.Ole Db.OleDbCommand Builder(jobList DataAdapter);

jobListDataTabl e = new System.Data.Dat aTable("Job List
Access DataTable");
jobListDataAdap ter.AcceptChang esDuringFill = true;
jobListDataAdap ter.AcceptChang esDuringUpdate = true;

jobListDataAdap ter.Fill(jobLis tDataTable);
...
}

Thanks,

--
George


Jun 16 '06 #3
Which table are you checking for the row state - jobListDataAdap ter or
oChangeDataTabl e?

"George" <wa**@nospam.no spam> wrote in message
news:14******** *************** ***********@mic rosoft.com...
The snippet only demonstrate how I setup AcceptChangesDu ringUpdate.

Eventually, at some other location I would have call

{
...
oChangeDataTabl e = this.jobListDat aTable.GetChang es();
if (oChangeDataTab le != null)
{
this.JobListDat aAdapter.Update (oChangeDataTab le);

foreach (System.Data.Da taRow oDataRow in
oChangeDataTabl e.Rows)
{
if (oDataRow[JobDataGridView ColumnId] ==
System.DBNull.V alue)
{
this.jobListDat aTable.Clear();

this.jobListDat aAdapter.Fill(t his.jobListData Table);
break;
}
}

jobListDataTabl e.AcceptChanges ();

...
}

After Update(), the RowState of changed rows seem to be updated to
"unchanged" from "Added", "Deleted".. . and what not.

However, without specifically calling DataTable.Accep tChanges(), the next
call to DataTable.GetCh anges() still returns a table of changed rows.

Any ideas?

--
George
"Marina Levit [MVP]" wrote:
You are only getting data into the table in this example. You are not
updating the database, so that property would not be relevant.

"George" <wa**@nospam.no spam> wrote in message
news:E0******** *************** ***********@mic rosoft.com...
>
> I have set DataAdapter.Acc eptChangesDurin gUpdate = true;
>
> However, I find that I still need to call AcceptChanges on the
> associated
> DataTable,
>
> DataTable.Accep tChanges();
>
> Has anyone encountered that? Am I not setting this field properly?
>
> The following are some of the snippets of the codes which may help
> explain
> what I was doing,
>
>
> //Setting DataAdapter.Acc eptChangesDurin gUpdate
> {
> ...
>
> jobListDataAdap ter = new
> System.Data.Ole Db.OleDbDataAda pter(commandStr ing, oOleDbConn);
>
> oOleDbCommandBu ilder = new
> System.Data.Ole Db.OleDbCommand Builder(jobList DataAdapter);
>
> jobListDataTabl e = new System.Data.Dat aTable("Job List
> Access DataTable");
> jobListDataAdap ter.AcceptChang esDuringFill = true;
> jobListDataAdap ter.AcceptChang esDuringUpdate = true;
>
> jobListDataAdap ter.Fill(jobLis tDataTable);
> ...
> }
>
>
>
> Thanks,
>
> --
> George


Jun 16 '06 #4
Hi Marina,

I figured out what I did wrong. I guess the reason is related to your
question as well.

I have called DataAdapter.Upd ate(oChangeData Table). I thought this will be
more efficient since it is a smaller or equal size table. However, the
AcceptChangesDu ringUpdate flag is causing oChangeDataTabl e.AccpetChanges () to
be called, while jobListDataTabl e's changes have not been accepted.

Now I changed my call to DataAdapter.Upd ate(jobListData Table) and it works
as I desired. I came across this while I was review my codes and realized
that DataAdapter does contain any reference to a particular DataTable. the
DataTable is passed into method's parameter.

Thanks for your help

--
George
"Marina Levit [MVP]" wrote:
Which table are you checking for the row state - jobListDataAdap ter or
oChangeDataTabl e?

"George" <wa**@nospam.no spam> wrote in message
news:14******** *************** ***********@mic rosoft.com...
The snippet only demonstrate how I setup AcceptChangesDu ringUpdate.

Eventually, at some other location I would have call

{
...
oChangeDataTabl e = this.jobListDat aTable.GetChang es();
if (oChangeDataTab le != null)
{
this.JobListDat aAdapter.Update (oChangeDataTab le);

foreach (System.Data.Da taRow oDataRow in
oChangeDataTabl e.Rows)
{
if (oDataRow[JobDataGridView ColumnId] ==
System.DBNull.V alue)
{
this.jobListDat aTable.Clear();

this.jobListDat aAdapter.Fill(t his.jobListData Table);
break;
}
}

jobListDataTabl e.AcceptChanges ();

...
}

After Update(), the RowState of changed rows seem to be updated to
"unchanged" from "Added", "Deleted".. . and what not.

However, without specifically calling DataTable.Accep tChanges(), the next
call to DataTable.GetCh anges() still returns a table of changed rows.

Any ideas?

--
George
"Marina Levit [MVP]" wrote:
You are only getting data into the table in this example. You are not
updating the database, so that property would not be relevant.

"George" <wa**@nospam.no spam> wrote in message
news:E0******** *************** ***********@mic rosoft.com...
>
> I have set DataAdapter.Acc eptChangesDurin gUpdate = true;
>
> However, I find that I still need to call AcceptChanges on the
> associated
> DataTable,
>
> DataTable.Accep tChanges();
>
> Has anyone encountered that? Am I not setting this field properly?
>
> The following are some of the snippets of the codes which may help
> explain
> what I was doing,
>
>
> //Setting DataAdapter.Acc eptChangesDurin gUpdate
> {
> ...
>
> jobListDataAdap ter = new
> System.Data.Ole Db.OleDbDataAda pter(commandStr ing, oOleDbConn);
>
> oOleDbCommandBu ilder = new
> System.Data.Ole Db.OleDbCommand Builder(jobList DataAdapter);
>
> jobListDataTabl e = new System.Data.Dat aTable("Job List
> Access DataTable");
> jobListDataAdap ter.AcceptChang esDuringFill = true;
> jobListDataAdap ter.AcceptChang esDuringUpdate = true;
>
> jobListDataAdap ter.Fill(jobLis tDataTable);
> ...
> }
>
>
>
> Thanks,
>
> --
> George


Jun 16 '06 #5
Hi George,

Yes, this is the case. In addition, you don't need to use GetChanges to get
the difference set to update as this will not improve performance, unless
you're passing the DataSet through a web-service.

Kevin Yu
Microsoft Online Community Support

=============== =============== =============== =============== =============== =
=============== ===========
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =============== =============== =
=============== ===========

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 19 '06 #6

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

Similar topics

0
2314
by: Dotnetified | last post by:
Reposting after about 2 weeks of no response ... thanks if you can help... ---------------------------------------------------------------------------- -------------- To anyone who thinks they know it all: ;) We recently upgraded our MSDN Version of VS.NET 2002 to VS.NET 2003... Things are all working well, except we've run across a new bug or issue since our adopting of the new package.
2
4273
by: hch | last post by:
dataAdapter.Update(data, "TableName") won’t work! I was about to deploy my first website on the Internet only to discover that the dataAdapter.Update() throws the Server Error in the third underline. It was working fine before. ConnectionString in Web.config: ----------------------------------------- <?xml version="1.0" encoding="utf-8" ?> <configuration>
20
1674
by: TJ Doherty | last post by:
Need help understanding the following please: When I am creating a project and code my connection using Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Temp\NW-test.MDB", everything works correctly when I run the project. However, if I set up the exact same connection using the DataAdapter wizard and try to run the project, I get a "Microsoft Jet database engine cannot open the file..." error.
6
1579
by: Geoff Pennington | last post by:
I have a class method that returns a DataAdapter. I want to access the table(s) contained in the DataAdapter. Of course, accessing the DataSets would be good enough, because I could get the tables from there. I can't find a way to do this. Am I missing something? Much obliged.
6
4741
by: Jack | last post by:
I have the following: * An OLEDBCommand with command text "SELECT CAMPAIGN, DAY_OUT WHERE (CAMPAIGN LIKE '@campaign')" * A DataAdapter that point the select to the above command * A data grid that I use to display the data * form load code to populate the controls: DsCampaign1 = New DataSet cmdProActiTmp_Sel.Parameters.Item("@Campaign").Value = _ Trim(txtcampaign.Text())
3
1879
by: Larry Woods | last post by:
I have a datagrid that is carrying all fields of a record...except one. Now I want to update the underlying database via a dataadapter. The update is working but the field that is "left out" is not there, of course. How do I get that field back into the datatable for the database update? TIA, Larry Woods
4
1789
by: astro | last post by:
I would like to build some generic code that is able to figure out the correct dataAdapter to apply changes to given a form with several dataAdapters. Any suggestions on the following? Thank you. ====================================== Private Sub SaveChanges(ByVal aContainer As Object)
8
2699
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. Example: I have a dataadapter that contains one table with one row. I change the value of the 'FisrtName' column in that row from Jack to John. I call ..update on the dataadapter it goes through fine. Now I change that same column in that same row...
4
11168
by: George | last post by:
Got a question about the side effect of DataAdapter.Update() and DataTable.GetChanges(). Say I set up a DataTable and a DataAdapter in a class. Delete (Not remove) a row in the data table and call the following method. public void JobListDataTableFromAccessCommitChange() { System.Data.DataTable oChangeDataTable;
0
9690
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
9551
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,...
0
10033
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
7576
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
5469
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
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
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.