473,785 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1363
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.GetUpdateCom mand();
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****@NOSPAMd evelop.com> wrote in message
news:b8******** *************** ***@msnews.micr osoft.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****@magnaca rtasoftware.com > wrote in message
news:uc******** ******@TK2MSFTN GP09.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.GetUpdateCom mand();
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******** ******@TK2MSFTN GP12.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****@magnaca rtasoftware.com > wrote in message
news:uc******** ******@TK2MSFTN GP09.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
ExecuteNonQue ry().


Dec 28 '05 #5

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

Similar topics

0
1112
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 systems specifications proposal (i.e. it's a case of "the blind leading the blind" :) ). I sure could use some words o' wisdom from you folks. I understand that there are two broad approaches to making databases for XML data. One is to build...
13
3111
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 120 records a minute. This may increase in the future to about 200. The records are not large. We have other workstations that run sessions on Terminal Server querying this MDB, doing things like plotting the last hours data on a graph or...
12
3767
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 question is about storing data in a database. Yes I understand that you can link to a database in your program and read and write to the database etc etc. Well, that's all find and dandy but what if the person you're writing the application for...
20
2036
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 developers will encounter when coming from the world of dedicated applications (VB, Delphi, etc.) I'm thinking of issues specific to web apps like the statelessness of HTTP, dealing with the back button, etc.
16
7189
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 unchanged). How can I do that in Python? Claudio Grondi
3
2519
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 sqlite3 database table. Here's the context: The OMR card reader sends a stream of 69 bytes over the serial line; the last byte is a carriage return ('\r') indicating the end of record. Three pairs (in specific positions at the beginning of the...
6
5274
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
2706
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 articles I have read about TDD, a good unit test does not rely on the database or other such external/environmental conditions. More generally, a good unit test is atomic and makes as few assumptions about its runtime environment as possible. But...
1
3863
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 parser and dbi/ odbc for my db connection. To fix problems with unicode I built a work-around by mapping unicode characters to equivalent ascii characters and then encoding everything to ascii. That allowed me to build the application and debug...
0
9480
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
10329
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, 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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7500
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
6740
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
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...
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
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.