Well, you've got a couple of issues to deal with here, and a little clarity
about what is going on will help.
First, it is important to understand that a DataSet is a container for
DataTables, and usually contains schema information about the database that
contains the tables as well. The DataSet is *not* connected to the Database,
but contains a *copy* of what is in the database. It is populated by a
DataAdapter, which *does* connect to the database when necessary to update
either the DataSet contents from the database or vice versa.
So, first of all, we're not doing anything with the DataSet, just a
DataTable or DataTables *in* the DataSet. And the question I need to know
the answer to is, do you want to copy or move data in the database from one
table to another, or do you simply want to work with data from 2 different
data sources in the same DataTable?
If you want to copy or move data from one table in the database to another,
there's no reason to involve a DataSet or a DataAdapter. You simply call a
Stored Procedure or execute a query to do it. If you want to combine data
from 2 different data sources, you append rows to the DataTable in one
DataSet from the rows in a DataTable in the other, or from a query or Stored
Procedure.
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
Hard work is a medication for which
there is no placebo.
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
Hello,
I am trying to write the data I got from a web service to my table in SQL
Server
I need to append the dataset wsDS to the dataset ds and do update.
PVS.myWS.Loader load = new PVS.myWS.Loader();
DataSet wsDS=load.WsLoad();
dataGrid1.DataSource=wsDS;
string strConn = ConfigurationSettings.AppSettings["connectionString"];
SqlConnection sqlConn = new SqlConnection(strConn);
DataSet ds = new DataSet();
SqlDataAdapter daRS = new SqlDataAdapter("SELECT * From myTable",
sqlConn);
SqlCommandBuilder cbRS = new SqlCommandBuilder(daRS);
sqlConn.Open();
daRS.Fill(ds,"myTable");
/* ??? here I need some code */
/* Append data in wsDS to ds to write it back to myTable */
daRS.Update(ds,"myTable");
sqlConn.Close();
Can anyone give me the easiest and fasted way?