日期:2014-05-18 浏览次数:20830 次
OracleConnection oconn = new OracleConnection(GetConnString()); OracleDataAdapter oda = new OracleDataAdapter("select * from t1", oconn); DataTable dt1 = new DataTable(); oda.Fill(dt1); OracleConnection oconn1 = new OracleConnection(GetConnString()); oconn1.Open(); OracleDataAdapter oda1 = new OracleDataAdapter("select * from t2", oconn1); DataTable dt2 = new DataTable(); oda1.Fill(dt2); --更新資料 foreach( DataRow row in dt1.Rows) { try { //import row : object [] row2 = row.ItemArray; dt2.BeginLoadData(); dt2.LoadDataRow(row2, false); dt2.EndLoadData(); } catch(Exception ex) { throw ex; } } OracleCommandBuilder ocb1 = new OracleCommandBuilder(oda1); oda1.Update(dt2); dt2.AcceptChanges(); oconn1.Close();