日期:2014-05-17 浏览次数:20524 次
SqlConnection pConn = new SqlConnection(connString);
SqlTransaction pTrans = null;
[align=left] try
{
pConn.Open();
pTrans = pConn.BeginTransaction();
using (SqlBulkCopy bcp = new SqlBulkCopy(pConn, SqlBulkCopyOptions.FireTriggers, pTrans))
{
bcp.DestinationTableName = "temp_" + tableName;
bcp.WriteToServer(data);
}
// 提交事务
pTrans.Commit();
pConn.Close();
}
catch (Exception ex)
{
pTrans.Rollback();
}[/align]