oracle大数据块添加

时间:2019-08-08 07:33:53
【文件属性】:

文件名称:oracle大数据块添加

文件大小:2KB

文件格式:TXT

更新时间:2019-08-08 07:33:53

oralce

///

/// 大数据块入库 /// /// /// public void BulkToDB(DataTable dt, string targetTable) { string err = "大批量插入时产生错误"; string conStr = PubConstant.ConnectionString; conStr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.29.98)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=ORCL)));User ID=bridgeSystest;Password=abc123"; Oracle.DataAccess.Client.OracleConnection conn = new Oracle.DataAccess.Client.OracleConnection(conStr); //System.Data.OracleClient.OracleConnection conn = new System.Data.OracleClient.OracleConnection(conStr); if (conn.State != ConnectionState.Open) { conn.Open(); } // Oracle.DataAccess.Client.OracleBulkCopy bulkCopy = new Oracle.DataAccess.Client.OracleBulkCopy(conn, OracleBulkCopyOptions.Default); Oracle.DataAccess.Client.OracleBulkCopy bulkCopy = new Oracle.DataAccess.Client.OracleBulkCopy(conn, OracleBulkCopyOptions.Default); bulkCopy.BatchSize = 100000; bulkCopy.BulkCopyTimeout = 260; bulkCopy.DestinationTableName = targetTable; try { if (conn.State != ConnectionState.Open) { conn.Open(); } // conn.Open(); if (dt != null && dt.Rows.Count != 0) { bulkCopy.WriteToServer(dt); } } catch (Exception ex) { // Log.WriteLog(err, ex); } finally { conn.Close(); if (bulkCopy != null) bulkCopy.Close(); } }


网友评论