日期:2014-05-18 浏览次数:20844 次
public void testBulk()
{ DateTime begin = DateTime.Now;
IDataProvider OracleDataPro = DataProvider.CreateDataProvider(DataProvider.DataProviderType.OracleDataProvider);
IDataReader oracleDr = (OracleDataReader)OracleDataPro.RetriveDataReader("select * from zfxfzb.xsjbxxb");
DataTable oracleDr = OracleDataPro.RetriveDataSet("select * from zfxfzb.xsjbxxb").Tables[0];
SqlDataAccess mySda = new SqlDataAccess();
mySda.GetExecute("truncate table XSJBXXB_TEMP");
using (SqlConnection localConn = mySda.GetSqlConnection())
{ localConn.Open();
using (SqlTransaction tran = localConn.BeginTransaction())
{
SqlBulkCopy bulkCopyOrders = new SqlBulkCopy(localConn, SqlBulkCopyOptions.Default, tran);
bulkCopyOrders.DestinationTableName="xsjbxxb_temp";
bulkCopyOrders.ColumnMappings.Add("XH", "XH");
bulkCopyOrders.ColumnMappings.Add("XM", "XM");
bulkCopyOrders.ColumnMappings.Add("XB", "XB");
bulkCopyOrders.ColumnMappings.Add("CSRQ", "CSRQ");
bulkCopyOrders.ColumnMappings.Add("ZZMM", "ZZMM");
bulkCopyOrders.ColumnMappings.Add("MZ", "MZ");
bulkCopyOrders.ColumnMappings.Add("JG", "JG");
bulkCopyOrders.ColumnMappings.Add("LYDQ", "LYDQ");
bulkCopyOrders.ColumnMappings.Add("XY", "XY");
bulkCopyOrders.ColumnMappings.Add("XI", "XI");
bulkCopyOrders.ColumnMappings.Add("ZYMC", "ZYMC");
bulkCopyOrders.ColumnMappings.Add("XZB", "XZB");
bulkCopyOrders.ColumnMappings.Add("XZ", "XZ");
bulkCopyOrders.ColumnMappings.Add("XXNX", "XXNX");
bulkCopyOrders.ColumnMappings.Add("XJZT", "XJZT");
bulkCopyOrders.ColumnMappings.Add("DQSZJ", "DQSZJ");
bulkCopyOrders.ColumnMappings.Add("PYFX", "PYFX");
bulkCopyOrders.ColumnMappings.Add("ZYFX", "ZYFX");
bulkCopyOrders.ColumnMappings.Add("ZYLB", "ZYLB");
bulkCopyOrders.ColumnMappings.A