DataSet ds = new DataSet();
using (SqlConnection conn = new SqlConnection(@"data source=.\sqlxu;initial catalog=NationalUnion20140717;persist security info=True;user id=sa;password=101;MultipleActiveResultSets=True"))
{
SqlDataAdapter da = new SqlDataAdapter("select * from [dbo].[ProductType]", conn);
da.Fill(ds);
}
string connTest = @"data source=10.57.40.184;initial catalog=NationalUnion;persist security info=True;user id=NationalUsers;password=P@ssw0rd;MultipleActiveResultSets=True";
//using (SqlConnection connTest = new SqlConnection())
//{
SqlBulkCopy sbc = new SqlBulkCopy(connTest, SqlBulkCopyOptions.UseInternalTransaction);
sbc.DestinationTableName = "[dbo].[ProductType]";
sbc.BulkCopyTimeout = 0;
sbc.WriteToServer(ds.Tables[0]);
利用DataTable快速批量导数据,布布扣,bubuko.com
原文:http://www.cnblogs.com/xuxu-dragon/p/3919801.html