//查询 private DbReader query(Command cmd, DbTran transaction) { if (false == buildCMD(cmd, (transaction == null ? null : transaction.connection), false)) { return(null); } //3.执行 DbReader rst = new DbReader(stmt.ExecuteReader()); //stmt.executeQuery(); //*.监听 WeedConfig.logExecuteAft(cmd); return(rst); }
public long insert(Command cmd, DbTran transaction) { try { if (false == buildCMD(cmd, (transaction == null ? null : transaction.connection), true)) { return(-1); } long rst = 0; if (stmt.CommandText.IndexOf("@@IDENTITY") > 0) { var obj = stmt.ExecuteScalar(); if (obj is ulong) { rst = (long)((ulong)obj); } else if (obj is long) { rst = (long)obj; } else { rst = 0; } } else { rst = stmt.ExecuteNonQuery(); } //*.监听 WeedConfig.logExecuteAft(cmd); return(rst); } catch (Exception ex) { WeedConfig.logException(cmd, ex); throw ex; } finally { tryClose(); } }
//执行 public int execute(Command cmd, DbTran transaction) { try { if (false == buildCMD(cmd, (transaction == null ? null : transaction.connection), false)) { return(-1); } int rst = stmt.ExecuteNonQuery(); //*.监听 WeedConfig.logExecuteAft(cmd); return(rst); } catch (Exception ex) { WeedConfig.logException(cmd, ex); throw ex; } finally { tryClose(); } }