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

Append DataSet To Existing Table

I am using VB ASP.NET. In my page I convert an uploaded XML file to a
dataset as follows:

Dim ds1 As DataSet = New DataSet

ds1.ReadXml(strPathName, XmlReadMode.Auto)

Now I want to append all the rows of ds1 to an existing table in an SQL
Server database. I know I can do things like looping through the dataset and
issuing Update SQL statements to do this but I suspect there is a better
way? I tried Google but am not getting any usable hits. Does anyone have a
suggestion on a better way to accomplish adding the contents of a dataset to
an existing table?

Wayne
Nov 18 '05 #1
5 2935
Hi Wayne,

You can use the DataAdapter class to get your changes from the DataSet into
the SQL Server database. Microsoft has published a HowTo article with some
sample source code on how to do this:
http://support.microsoft.com/kb/308055/EN-US/

Cheers,
Gwynn

-----------------------------------------------------------------
Gwynn Kruger
http://www.compusolvecanada.com
-----------------------------------------------------------------
"Wayne Wengert" wrote:
I am using VB ASP.NET. In my page I convert an uploaded XML file to a
dataset as follows:

Dim ds1 As DataSet = New DataSet

ds1.ReadXml(strPathName, XmlReadMode.Auto)

Now I want to append all the rows of ds1 to an existing table in an SQL
Server database. I know I can do things like looping through the dataset and
issuing Update SQL statements to do this but I suspect there is a better
way? I tried Google but am not getting any usable hits. Does anyone have a
suggestion on a better way to accomplish adding the contents of a dataset to
an existing table?

Wayne

Nov 18 '05 #2
Thanks for that pointer Gwynn. I'll check that out.

Wayne

"Gwynn Kruger" <Gw*********@discussions.microsoft.com> wrote in message
news:AF**********************************@microsof t.com...
Hi Wayne,

You can use the DataAdapter class to get your changes from the DataSet into the SQL Server database. Microsoft has published a HowTo article with some
sample source code on how to do this:
http://support.microsoft.com/kb/308055/EN-US/

Cheers,
Gwynn

-----------------------------------------------------------------
Gwynn Kruger
http://www.compusolvecanada.com
-----------------------------------------------------------------
"Wayne Wengert" wrote:
I am using VB ASP.NET. In my page I convert an uploaded XML file to a
dataset as follows:

Dim ds1 As DataSet = New DataSet

ds1.ReadXml(strPathName, XmlReadMode.Auto)

Now I want to append all the rows of ds1 to an existing table in an SQL
Server database. I know I can do things like looping through the dataset and issuing Update SQL statements to do this but I suspect there is a better
way? I tried Google but am not getting any usable hits. Does anyone have a suggestion on a better way to accomplish adding the contents of a dataset to an existing table?

Wayne

Nov 18 '05 #3
Gwynn;

That article seems to simply show how the Update, Insert and Delete commands
can be built when using a Select for a single table. The Update/Insert apply
to the original table. In my case, I am getting the dataset from an XML file
and writing the output to an SQL table. For right now I simply coded the
Insert command manually but it seems like there ought to be a more efficient
way?

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:On**************@TK2MSFTNGP09.phx.gbl...
Thanks for that pointer Gwynn. I'll check that out.

Wayne

"Gwynn Kruger" <Gw*********@discussions.microsoft.com> wrote in message
news:AF**********************************@microsof t.com...
Hi Wayne,

You can use the DataAdapter class to get your changes from the DataSet into
the SQL Server database. Microsoft has published a HowTo article with some
sample source code on how to do this:
http://support.microsoft.com/kb/308055/EN-US/

Cheers,
Gwynn

-----------------------------------------------------------------
Gwynn Kruger
http://www.compusolvecanada.com
-----------------------------------------------------------------
"Wayne Wengert" wrote:
I am using VB ASP.NET. In my page I convert an uploaded XML file to a
dataset as follows:

Dim ds1 As DataSet = New DataSet

ds1.ReadXml(strPathName, XmlReadMode.Auto)

Now I want to append all the rows of ds1 to an existing table in an SQL Server database. I know I can do things like looping through the dataset and issuing Update SQL statements to do this but I suspect there is a
better way? I tried Google but am not getting any usable hits. Does anyone
have a suggestion on a better way to accomplish adding the contents of a dataset to an existing table?

Wayne


Nov 18 '05 #4
Wayne,

What do you mean by more efficient? More efficient as in less source code or
more efficient as in executing faster during runtime?

The article shows how you specify a Select statement for the DataAdapter so
that the CommandBuilder can dynamically determine the SQL needed to execute
the Update, Insert, and Delete commands. This helps out if you're not all
that familiar with SQL.

It sounds like you've coded up the Insert statement yourself in which case
you wouldn't need the CommandBuilder code but would still need to use the
DataAdapter to update the SQL Database.

Could you please post your source code so I can check it out?

Cheers,
Gwynn

-----------------------------------------------------------------
Gwynn Kruger
http://www.compusolvecanada.com
-----------------------------------------------------------------

"Wayne Wengert" wrote:
Gwynn;

That article seems to simply show how the Update, Insert and Delete commands
can be built when using a Select for a single table. The Update/Insert apply
to the original table. In my case, I am getting the dataset from an XML file
and writing the output to an SQL table. For right now I simply coded the
Insert command manually but it seems like there ought to be a more efficient
way?

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:On**************@TK2MSFTNGP09.phx.gbl...
Thanks for that pointer Gwynn. I'll check that out.

Wayne

"Gwynn Kruger" <Gw*********@discussions.microsoft.com> wrote in message
news:AF**********************************@microsof t.com...
Hi Wayne,

You can use the DataAdapter class to get your changes from the DataSet

into
the SQL Server database. Microsoft has published a HowTo article with some sample source code on how to do this:
http://support.microsoft.com/kb/308055/EN-US/

Cheers,
Gwynn

-----------------------------------------------------------------
Gwynn Kruger
http://www.compusolvecanada.com
-----------------------------------------------------------------
"Wayne Wengert" wrote:

> I am using VB ASP.NET. In my page I convert an uploaded XML file to a
> dataset as follows:
>
> Dim ds1 As DataSet = New DataSet
>
> ds1.ReadXml(strPathName, XmlReadMode.Auto)
>
> Now I want to append all the rows of ds1 to an existing table in an SQL > Server database. I know I can do things like looping through the dataset
and
> issuing Update SQL statements to do this but I suspect there is a

better > way? I tried Google but am not getting any usable hits. Does anyone

have
a
> suggestion on a better way to accomplish adding the contents of a

dataset to
> an existing table?
>
>
>
> Wayne
>
>
>



Nov 18 '05 #5
I create the dataset from an XML file. I do not issue any Select statement.
That is part of the difference!

Wayne

"Gwynn Kruger" <Gw*********@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
Wayne,

What do you mean by more efficient? More efficient as in less source code or more efficient as in executing faster during runtime?

The article shows how you specify a Select statement for the DataAdapter so that the CommandBuilder can dynamically determine the SQL needed to execute the Update, Insert, and Delete commands. This helps out if you're not all
that familiar with SQL.

It sounds like you've coded up the Insert statement yourself in which case
you wouldn't need the CommandBuilder code but would still need to use the
DataAdapter to update the SQL Database.

Could you please post your source code so I can check it out?

Cheers,
Gwynn

-----------------------------------------------------------------
Gwynn Kruger
http://www.compusolvecanada.com
-----------------------------------------------------------------

"Wayne Wengert" wrote:
Gwynn;

That article seems to simply show how the Update, Insert and Delete commands can be built when using a Select for a single table. The Update/Insert apply to the original table. In my case, I am getting the dataset from an XML file and writing the output to an SQL table. For right now I simply coded the
Insert command manually but it seems like there ought to be a more efficient way?

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:On**************@TK2MSFTNGP09.phx.gbl...
Thanks for that pointer Gwynn. I'll check that out.

Wayne

"Gwynn Kruger" <Gw*********@discussions.microsoft.com> wrote in message news:AF**********************************@microsof t.com...
> Hi Wayne,
>
> You can use the DataAdapter class to get your changes from the DataSet into
> the SQL Server database. Microsoft has published a HowTo article with
some
> sample source code on how to do this:
> http://support.microsoft.com/kb/308055/EN-US/
>
> Cheers,
> Gwynn
>
> -----------------------------------------------------------------
> Gwynn Kruger
> http://www.compusolvecanada.com
> -----------------------------------------------------------------
>
>
> "Wayne Wengert" wrote:
>
> > I am using VB ASP.NET. In my page I convert an uploaded XML file
to a > > dataset as follows:
> >
> > Dim ds1 As DataSet = New DataSet
> >
> > ds1.ReadXml(strPathName, XmlReadMode.Auto)
> >
> > Now I want to append all the rows of ds1 to an existing table in

an SQL
> > Server database. I know I can do things like looping through the

dataset
and
> > issuing Update SQL statements to do this but I suspect there is a

better
> > way? I tried Google but am not getting any usable hits. Does
anyone have
a
> > suggestion on a better way to accomplish adding the contents of a
dataset to
> > an existing table?
> >
> >
> >
> > Wayne
> >
> >
> >


Nov 18 '05 #6

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

Similar topics

2
by: JMCN | last post by:
hi i have a general question regarding append queries in access 97. each week i need to update my table(tblonlinereg) with new or modified records. firstly, i import the text file into my...
6
by: Sven Pran | last post by:
Probably the answer is there just in front of me only awaiting me to discover it, but: 1: I want to build a query that returns all records in one table for which there is no successful "join"...
3
by: Peter | last post by:
I have an Access database and it has several tables, I would like to export some of the data from those tables into one XML file. Is there a way to append data to XML file or merge all the data...
5
by: Steven C | last post by:
Hello: I am trying to append a dataset that draws its data from a MSDE instance, and I keep getting the exception: Can't create a child list for field tblCustomers. conn = new...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
3
by: P K | last post by:
Hello, I have a dataset which is already loaded with data in one table. so dataset.tables("data") exists and has data. Now, I have to add another table to the dataset. The source for this...
4
by: Al | last post by:
I have this scenario: 1. XML file with schema and data is created from SQL Server tables. XML file contains 6 tables, some of them have rows, some of them are empty. 2. XML file is given to the...
4
by: MN | last post by:
I have to import a tab-delimited text file daily into Access through a macro. All of the data needs to be added to an existing table. Some of the data already exists but may be updated by the...
2
by: SePp | last post by:
Hi, I have one dataset which is exported to an external file (excel) My problem is that I want to append the data of two different views to one dataset. (because they have to be displayed in an...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.