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 2454
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 object from a copy of another object of the same...
|
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 = new double;
|
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
there have faster method. The following code...
|
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 going
down and stop responding, this is when i'm...
|
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 was easy. But
pasting an image from 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 and using COPY TO to write then to file....
|
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 show
what I tried thusfar. Because it's not about a...
|
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 can see logs for different day in one file only.
...
|
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, provide the links or keyword search to find them. I’ve...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |