Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to save datatable to different table and database

Status
Not open for further replies.

4RRRR

Programmer
Mar 11, 2004
34
US
Hi All,

I am kinda struggling to write code for saving datatable from one table to another table in another database, basically I am trying to write datacopy from one table to another table which is in different databse.

I have one tabel tblCountry in SQL databse with 2 coulumns, I need load the data into tblCOuntryExt in Oracle databse with 4 columns.
Now I need to map the columns and load the data.

foreach( DataRow row in expDataTable.Rows)
{
DataRow rw = impDataTable.NewRow();
rw["CountryName"] = row["CountryName"];
rw["ClientId"] = row["parmClient"];
impDataTable.Rows.Add(rw);
}
impDataTable.TableName = "tblCOuntryExt";
then I dont knwo what to do .......... I am stuck here...

Thanks a lot for any help here.



 
open connection to database 1.
create command.
populate datatable.
dispose of object related to database1.
open connection to database 2.
create command
use datatable to populate parameters.
save
dispose of objects related to database 2.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I am sorry, I did not get "use datatable to populate parameters."

can you please give me some code samples.

thanks a lot.
 
as in a parameterized sql query. there are plenty of examples on the net. google "Ado.Net IDbCommand" and "parameterized sql queries" for more information.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
hi Jason Meckley,

my case i have datatable, i dont know how can I setup a parameterized sql.

I checked google, i found some parameterized sql, i think in that case i need to loop through each record and form a insert sql, right?

please share code snippets, if you can. thanks a lot
 
yes loop through the records in the datatable and process each record as a new command.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top