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

Updated dataset back to the database

Roy
Hi all,

I've filled a dataset from a select dataadapter. Dataset has been modified
and I need to send changes back to the database. Since dataadapter has been
disposed, what is the code to send these changes to the database.
Thanks,

Roy
Jul 21 '05 #1
2 1283
Roy - the way Updates work is that a given dataadapter loops through each
row of a datatable and checks the rowstate. If none of the rowstates have
changed, nothing happens. But let's say that a Row has been deleted. It
will look to the DeleteCommand for the dataadapter and fire it. The same
process is done for each of the other types of commands - insert and update.

If you want to use DataAdater.Update(DataTable) syntax - then you'll need a
configured adapter - either by creating a new one with those commands
configured correctly or not disposing of the first one and using it again -
but the key is that ANY adapter will work, but it must have each command
configured correctly for each rowstate that you have. So if you have no
Deleted rows, then you don't need a delete command.

The other choice is walking through the datatable yourself, getting the
values that have changed, and calling a ExecuteNonQuery (or one of the other
Executes) to fire the commands one at a time - after all that's all the
adapter is doing for you.

If possible, calling DataAdapter.Update is the cleanest and easiest to
maintain. So even if the adapter is disposed and you can't change that -
you only need the Update, Insert and Delete commands - which you cna feed to
a new adapter and just call .Update.

HTH,

Bill

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Roy" <Ro*@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.com...
Hi all,

I've filled a dataset from a select dataadapter. Dataset has been modified
and I need to send changes back to the database. Since dataadapter has been disposed, what is the code to send these changes to the database.
Thanks,

Roy

Jul 21 '05 #2
Roy

"So even if the adapter is disposed and you can't change that -
you only need the Update, Insert and Delete commands "
Ryan, Would you provide a sample code for this scenario?
Thanks again
Roy
"W.G. Ryan eMVP" wrote:
Roy - the way Updates work is that a given dataadapter loops through each
row of a datatable and checks the rowstate. If none of the rowstates have
changed, nothing happens. But let's say that a Row has been deleted. It
will look to the DeleteCommand for the dataadapter and fire it. The same
process is done for each of the other types of commands - insert and update.

If you want to use DataAdater.Update(DataTable) syntax - then you'll need a
configured adapter - either by creating a new one with those commands
configured correctly or not disposing of the first one and using it again -
but the key is that ANY adapter will work, but it must have each command
configured correctly for each rowstate that you have. So if you have no
Deleted rows, then you don't need a delete command.

The other choice is walking through the datatable yourself, getting the
values that have changed, and calling a ExecuteNonQuery (or one of the other
Executes) to fire the commands one at a time - after all that's all the
adapter is doing for you.

If possible, calling DataAdapter.Update is the cleanest and easiest to
maintain. So even if the adapter is disposed and you can't change that -
you only need the Update, Insert and Delete commands - which you cna feed to
a new adapter and just call .Update.

HTH,

Bill

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Roy" <Ro*@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.com...
Hi all,

I've filled a dataset from a select dataadapter. Dataset has been modified
and I need to send changes back to the database. Since dataadapter has

been
disposed, what is the code to send these changes to the database.
Thanks,

Roy


Jul 21 '05 #3

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

Similar topics

40
by: Peter Row | last post by:
Hi all, Here is my problem: I have a SQL Server 2000 DB with various NVarChar, NText fields in its tables. For some stupid reason the data was inserted into these fields in UTF8 encoding. ...
4
by: Frnak McKenney | last post by:
I'm using an in-core DataSet as an image of my application's 'database' (a multi-table Access97 mdb file). Updates are made to the DataTables within the DataSet via forms with bound TextBoxes,...
6
by: Lester Moreno | last post by:
Hello all, Up to now C# have been an great experience but I found myself in a end of the road problem. Let say that you have two windows program running on a local network area. User1 and...
4
by: Jaime | last post by:
I have to save a dataset to xml and for efficiency I like to get rid of the namespace prefix d2p1: can any one help thanks jaime
7
by: Shaine Fisher | last post by:
I have had a look around but I'm either not finding or not seeing the answer to this, what i want to do is reurn the results as an array, or some other worldly useful format that flash mx2004 can...
0
by: Vijay Balki | last post by:
I am fetching data in DataSet - myDataSet, from a remote database using a Web Service in my VB.NET client..Once I fetch it I store the data in XML file (myXMLFile) using the WriteXML method of the...
2
by: Roy | last post by:
Hi all, I've filled a dataset from a select dataadapter. Dataset has been modified and I need to send changes back to the database. Since dataadapter has been disposed, what is the code to send...
13
by: processoriented | last post by:
I am trying to find the best approach to do something here... situation is this... One of the tables in my dataset is a "Work Order" table with information about what needs to be done and where. ...
1
by: Creini | last post by:
Hi, I'm trying to write a Webapplication in ASP.Net 3.5 and C#. I read data from a database and Bind it to a FormView using <%# Eval("Columname") %> Which works quite well. But I have no...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.