日期:2014-05-17 浏览次数:20426 次
using (OracleDataAdapter da = new OracleDataAdapter()) { try { string strSQL="Select * from t1"; OpenConn();//打开连接 OracleCommand cmd; OracleParameter parm; DataTable dt = new DataTable(); cmd = new OracleCommand(strSQL, conn); da.SelectCommand = cmd; da.Fill(dt); string delsql = "DELETE FROM t1 WHERE ID=:pID"; cmd = new OracleCommand(delsql, conn); parm = cmd.Parameters.Add(":pID", OracleType.VarChar, 50, "ID"); parm.SourceVersion = DataRowVersion.Original; da.DeleteCommand = cmd; // int a = da.Update(dt); } catch (Exception ex) { //省略 } }
adapter.Fill(dt); dt.Rows[1].Delete();//删除DataTable中的某一行,根据需要自行删除 adapter.DeleteCommand = com; adapter.Update(dt);