void transfer(string table_name)
{
// Establishing connection
SqlConnection cnn = existing_database;
// Getting source data
SqlCommand cmd = new SqlCommand("SELECT * FROM " + table_name, cnn);
cnn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
// Initializing an SqlBulkCopy object
SqlBulkCopy sbc = new SqlBulkCopy(destination_database);
destination_database.Open();
// Copying data to destination
sbc.DestinationTableName = table_name;
sbc.WriteToServer(rdr);
// Closing connection and the others
sbc.Close();
rdr.Close();
cnn.Close();
}
Enjoy :) Jai Mata Di, Jai SiyaRam
{
// Establishing connection
SqlConnection cnn = existing_database;
// Getting source data
SqlCommand cmd = new SqlCommand("SELECT * FROM " + table_name, cnn);
cnn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
// Initializing an SqlBulkCopy object
SqlBulkCopy sbc = new SqlBulkCopy(destination_database);
destination_database.Open();
// Copying data to destination
sbc.DestinationTableName = table_name;
sbc.WriteToServer(rdr);
// Closing connection and the others
sbc.Close();
rdr.Close();
cnn.Close();
}
Enjoy :) Jai Mata Di, Jai SiyaRam
No comments:
Post a Comment