I want the code for copy data from one sql to another sql (Using C#)
When I click the Button
Copy my db2_connect Database data like:
select * from importdb where bhand = 3 and store = 14To my another database which is: abdConnection
in abdConnection Table is importabd and filed is same (bhand)
Can someone write the complete code.
Thanking You
Jignesh TrivediPosted Mar 27, 2014, 5:27 AM
hi,
I think if you have OLEDB connection so you must have OleDbDataReader.
try
OleDbDataReader readerr = command.ExecuteReader();
same as for odbc connection you must have OdbcDataReader...
hope this will help you.
Junaid SoomroPosted Mar 27, 2014, 5:13 AM
error line: SqlDataReader readerr = command.ExecuteReader();
Jignesh TrivediPosted Mar 26, 2014, 7:14 AM
hi,
I think SQL bulk copy feature can help you.
try..
//fill you data set to one server..
DataSet ds = FillData();
//Create connetion for other Server...
SqlConnection sCon = new SqlConnection(@"Other data base connection string");
System.Data.SqlClient.SqlBulkCopy bc = new SqlBulkCopy(sCon);
bc.DestinationTableName = "Destination table Name";
sCon.Open();
bc.WriteToServer(ds.Tables[0]);
bc.Close();
sCon.Close();
hope this will help you.