469,272 Members | 1,627 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

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 2786
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by JMCN | last post: by
3 posts views Thread by Peter | last post: by
5 posts views Thread by Steven C | last post: by
3 posts views Thread by P K | last post: by
4 posts views Thread by Al | last post: by
2 posts views Thread by SePp | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.