我想在c#控制台应用程序中将数据从DB2表传输到SQL Server。在下面使用代码的两个地方,我都有相同的架构
string connectionstring = ("Database = vvv ; UserID = ggg; Password = jjj");
string querystring = "select * from Employee" ;
using (DB2Connection con = new DB2Connection(connectionstring))
{
using (DB2Command cmd = new DB2Command((querystring))
{
cmd.Connection = con;
con.Open();
Console.Write("Loading data");
using (DB2DataAdapter da = new DB2DataAdapter(cmd))
{
DataTable dt = new DataTable("Employee");
da.Fill(dt);
string connection = @"SERVER = something here; uid = sdf; password = fgh; database =ggg;Integrated Security=True";
using (var bulkCopy = new SqlBulkCopy(connection))
{
foreach (DataColumn col in dt.Columns)
{
bulkCopy.ColumnMappings.Add(col.ColumnName, col.ColumnName);
}
//bulkCopy.BulkCopyTimeout = 600;
bulkCopy.NotifyAfter = 10000;
bulkCopy.DestinationTableName = "dbo.Employee";
bulkCopy.WriteToServer(dt);
}
}
con.Close();
}
}
}
}
}
将数据从适配器加载到数据集将近1到1.5个小时
da.Fill(dt); ---here
请提供解决方案。