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

Writing data back to a database

I have some data in a DataSet and want to write it back to the underlying
SQL Server database. Is there any simple "one-liner" way to write a dataset
back to its database or do I have to go through the steps of creating a
command object, adding parameters and calling ExecuteNonQuery().

Many thanks.
Dec 24 '05 #1
4 1340
Look into the SqlDataAdapter and its Update method.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have some data in a DataSet and want to write it back to the
underlying SQL Server database. Is there any simple "one-liner" way to
write a dataset back to its database or do I have to go through the
steps of creating a command object, adding parameters and calling
ExecuteNonQuery().

Many thanks.

Dec 24 '05 #2
Thanks. I read that and am now attempting to automatically generate the
update command. I can see that the command is created by examining:
SqlCommand com = cb.GetUpdateCommand();
However changes are still not appearing in the database when I call the
Update() method on the data adaptor instance. Examining the DataAdapter
members I notice that cmdUpdate is 'undefined value'. I have no idea why.
Are their any reasons for this that you can think of?

Many thanks.

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
Look into the SqlDataAdapter and its Update method.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have some data in a DataSet and want to write it back to the
underlying SQL Server database. Is there any simple "one-liner" way to
write a dataset back to its database or do I have to go through the
steps of creating a command object, adding parameters and calling
ExecuteNonQuery().

Many thanks.


Dec 27 '05 #3
Hi Andrew,

See if this helps: "How to update a database from a DataSet object by using
Visual Basic .NET" (http://support.microsoft.com/kb/q301248/) . Basically
the procedure is to make the changes you want to the data in the DataSet,
and then pass the Dataset object to the Update method of the DataAdapter
object. You will need to specify the InsertCommand, UpdateCommand, and
DeleteCommand properties of the DataAdapter or you can let VS generate these
for you.

--
Cindy Winegarden MSCD, Microsoft Visual FoxPro MVP
ci**************@msn.com www.cindywinegarden.com
"Andrew Chalk" <ac****@magnacartasoftware.com> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
I have some data in a DataSet and want to write it back to the underlying
SQL Server database. Is there any simple "one-liner" way to write a dataset
back to its database or do I have to go through the steps of creating a
command object, adding parameters and calling ExecuteNonQuery().

Dec 28 '05 #4
Thanks. I read about that and am now attempting to automatically generate
the
update command. I can see that the command is created by examining:
SqlCommand com = cb.GetUpdateCommand();
However changes are still not appearing in the database when I call the
Update() method on the data adaptor instance. Examining the DataAdapter
members I notice that cmdUpdate is 'undefined value'. I have no idea why.
Are their any reasons for this that you can think of?

Many thanks.

"Cindy Winegarden" <ci**************@msn.com> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
Hi Andrew,

See if this helps: "How to update a database from a DataSet object by
using Visual Basic .NET" (http://support.microsoft.com/kb/q301248/) .
Basically the procedure is to make the changes you want to the data in the
DataSet, and then pass the Dataset object to the Update method of the
DataAdapter object. You will need to specify the InsertCommand,
UpdateCommand, and DeleteCommand properties of the DataAdapter or you can
let VS generate these for you.

--
Cindy Winegarden MSCD, Microsoft Visual FoxPro MVP
ci**************@msn.com www.cindywinegarden.com
"Andrew Chalk" <ac****@magnacartasoftware.com> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
I have some data in a DataSet and want to write it back to the underlying
SQL Server database. Is there any simple "one-liner" way to write a
dataset back to its database or do I have to go through the steps of
creating a command object, adding parameters and calling
ExecuteNonQuery().


Dec 28 '05 #5

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

Similar topics

0
by: Irving Kimura | last post by:
At work I've been assigned the task of writing a brief (1-2 pages) report on the state-of-the-art of XML databases. The goal of this report is to inform a working group on possible choices for a...
13
by: Jeff Pritchard | last post by:
I have an MDB that contains a single table. Checkweigher data is being continuously written to this MDB from a dedicated workstation over a network into the MDB on the server at the rate of about...
12
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My...
20
by: Vincent Delporte | last post by:
Hello I'm about to write a prototype for a business application, but since this my first real web application, I'm looking for a good book or article that sums up the different issues web...
16
by: Claudio Grondi | last post by:
I have a 250 Gbyte file (occupies the whole hard drive space) and want to change only eight bytes in this file at a given offset of appr. 200 Gbyte (all other data in that file should remain...
3
by: Rich Shepard | last post by:
I need to learn how to process a byte stream from a form reader where each pair of bytes has meaning according to lookup dictionaries, then use the values to build an array of rows inserted into a...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
30
by: Cramer | last post by:
I've finally gotton board with TDD (test driven development) and wow is it effective! I went from sceptic to True Believer with my first effort. My question: According to the various books and...
1
by: Mudcat | last post by:
In short what I'm trying to do is read a document using an xml parser and then upload that data back into a database. I've got the code more or less completed using xml.etree.ElementTree for the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.