日期:2014-05-17  浏览次数:20483 次

调用RunProcedure时(string storedProcName, IDataParameter[] parameters, out int row)
/// 执行存储过程,返回执行结果和影响行数 
  /// </summary>
  /// <param name="storedProcName">存储过程名</param>
  /// <param name="parameters">存储过程参数</param>
  /// <param name="rowsAffected">影响的行数</param>
  /// <returns></returns>
  public static int RunProcedure(string storedProcName, IDataParameter[] parameters, out int rowsAffected)
  {
  using (SqlConnection connection = new SqlConnection(connectionString))
  {
  int result;
  connection.Open();
  SqlCommand command = BuildIntCommand(connection, storedProcName, parameters);
  rowsAffected = command.ExecuteNonQuery();
  result = (int)command.Parameters["ReturnValue"].Value;
  connection.Close();
  return result;
  }
  }

用RunProcedure时RunProcedure(string storedProcName, IDataParameter[] parameters, out int row)第三个参数填什么,详细点,谢谢

------解决方案--------------------
调用的时候
int rowsAffected=0;
RunProcedure("存储过程名字", 参数数组, out int rowsAffected)
rowsAffected = command.ExecuteNonQuery();
执行之后
这里 rowsAffected 时候执行成功 rowsAffected >0
失败 rowsAffected ==0