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? 4 2356
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?
Hi Kevin,
Thank you very much for your reply.
Here is what I am trying to do:
1. Call web service and get data from a remote database (working see my
previous message for the code)
2. put data to a dataset (working)
3. show it in the data grid (working)
4. and put this data in my local database (how? I need to write this code)
How can I do this 4th step? Any idea and sample code will be appreciated.
"Kevin Spencer" wrote: 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?
Hi Jim,
Okay, just a little more detail: 2. put data to a dataset (working) 3. show it in the data grid (working) 4. and put this data in my local database (how? I need to write this code)
You're putting data from a Web Service call into a DataSet. Then you're
displaying it in a DataGrid.
My oney question is, between #3 an #4, what is the connection? IOW, why
don't you just put it into your database, and then populate your DataSet
from your database? Is there some kind of time gap or other operation
between these 2 operations?
--
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:12**********************************@microsof t.com... Hi Kevin, Thank you very much for your reply. Here is what I am trying to do: 1. Call web service and get data from a remote database (working see my previous message for the code) 2. put data to a dataset (working) 3. show it in the data grid (working) 4. and put this data in my local database (how? I need to write this code)
How can I do this 4th step? Any idea and sample code will be appreciated. "Kevin Spencer" wrote:
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? >
Hi Kavin,
Ok thanks for the reply again. Here is the steps I was mentioning.
1. PVS.myWS.Loader load = new PVS.myWS.Loader();
2. DataSet wsDS=load.WsLoad();
3. dataGrid1.DataSource=wsDS;
This three steps show data in the grid in my application. Web service brings
this data from a remote database over internet which I do not have direct
connection.
Ok. If I can put the data into a table I can populate dataset from my
database. As you see web service returns a dataset. Can you tell me how can I
put the data directly into table and fill my dataset from there?
Thanks you very much for your help.
"Kevin Spencer" wrote: Hi Jim,
Okay, just a little more detail:
2. put data to a dataset (working) 3. show it in the data grid (working) 4. and put this data in my local database (how? I need to write this code)
You're putting data from a Web Service call into a DataSet. Then you're displaying it in a DataGrid.
My oney question is, between #3 an #4, what is the connection? IOW, why don't you just put it into your database, and then populate your DataSet from your database? Is there some kind of time gap or other operation between these 2 operations?
-- 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:12**********************************@microsof t.com... Hi Kevin, Thank you very much for your reply. Here is what I am trying to do: 1. Call web service and get data from a remote database (working see my previous message for the code) 2. put data to a dataset (working) 3. show it in the data grid (working) 4. and put this data in my local database (how? I need to write this code)
How can I do this 4th step? Any idea and sample code will be appreciated. "Kevin Spencer" wrote:
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? > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Edward Diener |
last post by:
Coming from the C++ world I can not understand the reason why copy
constructors are not used in the .NET framework. A copy constructor creates
an...
|
by: xuatla |
last post by:
Hi,
How to copy a pointer to another pointer?
Can I do in the following way:
// START
double *copyfrom = new double;
double *copyto =...
|
by: Yudan Yi |
last post by:
I have a problem to copy (assign) a matrix to another matrix. Curreny, I
know copy the number using loops, while it will take some time, I wonder if...
|
by: luis molina Micasoft |
last post by:
it seems that when i do file.copy the svchost.exe is hanged, i mean if i make
40 threads of file.copy , 40 copys of files at same time the system is...
|
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard...
|
by: Clodoaldo Pinto Neto |
last post by:
Hello,
How to make sure COPY TO writes the table lines to the file in the same order
they were inserted?
I'm producing html pages in pl/pgsql...
|
by: Jeroen |
last post by:
Hi all,
I'm trying to implement a certain class but I have problems regarding
the copy ctor. I'll try to explain this as good as possible and...
|
by: maheshkadam |
last post by:
Hi friends
I am new to perl so please guide me.
I have one application which created backup log file every day.But it appends that file so you...
|
by: Taxman |
last post by:
Windows XP, MS Office Excel 2003
If the tasks, I’m trying accomplish have been addressed previously (separately or in combination). Please,...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
| |