public bool insertOracle(DataTable dataTable, string sql) // Oracle sql 查询的是表头 { string ConnStr = WirelessCenterDAL.Common.GetConnDMS1; using (OracleConnection conn = new OracleConnection(ConnStr)) { try { OracleCommand cmd = new OracleCommand(sql, conn); OracleDataAdapter adapter = new OracleDataAdapter(cmd); OracleCommandBuilder cb = new OracleCommandBuilder(adapter); DataTable dsNew = new DataTable(); int count = adapter.Fill(dsNew); for (int i = 0; i < dataTable.Rows.Count; i++) { DataRow dr = dsNew.NewRow(); for (int j = 0; j < dataTable.Columns.Count; j++) { dr[dsNew.Columns[j].ColumnName] = dataTable.Rows[i][j]; } dsNew.Rows.Add(dr); } count = adapter.Update(dsNew); adapter.UpdateBatchSize = 5000; //adapter.Update(dataTable); return true; } catch (Exception ex) { //LogHelper.WriteErrLog("insertOracle", ex.Message); return false; } } }
时间: 2024-11-08 09:42:27