Ejemplo n.º 1
0
 public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
 {
     try
     {
         SqlCommand cmd = new SqlCommand();
         PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
         int val = cmd.ExecuteNonQuery();
         cmd.Parameters.Clear();
         return(val);
     }
     catch (Exception ex)
     {
         MessageLog.AddErrorLogDbSql("DbHelperSql", "ExecuteNonQuery:" + ex.Message);
         return(-1);
     }
 }
Ejemplo n.º 2
0
 public static int ExecuteScalar(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
 {
     try
     {
         SqlCommand cmd = new SqlCommand();
         PrepareCommand(cmd, connection, cmdType, cmdText, commandParameters);
         object obj = cmd.ExecuteScalar();
         cmd.Parameters.Clear();
         return(ObjectToInt32(obj));
     }
     catch (Exception ex)
     {
         MessageLog.AddErrorLogDbSql("DbHelperSql", "ExecuteScalar:" + ex.Message);
         return(-1);
     }
 }
Ejemplo n.º 3
0
 private static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
 {
     try
     {
         SqlCommand cmd = new SqlCommand();
         cmd.CommandTimeout = 60;
         using (SqlConnection connection = new SqlConnection(connectionString))
         {
             PrepareCommand(cmd, connection, cmdType, cmdText, commandParameters);
             int num = cmd.ExecuteNonQuery();
             cmd.Parameters.Clear();
             return(num);
         }
     }
     catch (Exception ex)
     {
         MessageLog.AddErrorLogDbSql("DbHelperSql", "ExecuteNonQuery:" + ex.Message);
         return(-1);
     }
 }