发布网友 发布时间:2022-04-20 01:38
共2个回答
懂视网 时间:2022-04-29 22:02
/// <summary> 2 /// 批量插入数据 3 /// </summary> 4 /// <param name="table">数据表</param> 5 /// <param name="targetTableName">数据库目标表名</param> 6 /// <returns></returns> 7 public static bool ExcuteBulkData(DataTable table, string targetTableName) 8 { 9 bool result = false; 10 using (ODAC.OracleConnection conn = new ODAC.OracleConnection(connStr)) 11 { 12 using (ODAC.OracleBulkCopy bulkCopy = new ODAC.OracleBulkCopy(connStr, ODAC.OracleBulkCopyOptions.Default)) 13 { 14 if (table != null && table.Rows.Count > 0) 15 { 16 bulkCopy.DestinationTableName = targetTableName; 17 for (int i = 0; i < table.Columns.Count; i++) 18 { 19 string col=table.Columns[i].ColumnName; 20 bulkCopy.ColumnMappings.Add(col, col); 21 } 22 conn.Open(); 23 bulkCopy.WriteToServer(table); 24 result = true; 25 } 26 } 27 } 28 return result; 29 } Oracle批量插入
OracleBulkCopy批量插入数据
标签:
热心网友 时间:2022-04-29 19:10
可以使用oracle