/// <summary> /// 获取某表中的总记录数 /// </summary> /// <param name="tablename">表名</param> /// <returns></returns> public static int GetRecordCount(string tablename) { string s = "select count(*) from {0}"; s = string.Format(s, tablename); return(Convert.ToInt32(SqlHelper3.ExecuteScalar(connString, CommandType.Text, s))); }
/// <summary> /// 获取指定表中指定字段的最大值 /// </summary> /// <param name="connectionString">数据库连接字符串</param> /// <param name="tableName">表名称</param> /// <param name="field">字段</param> /// <returns>Return Type:Int</returns> public static int GetMaxID(string connectionString, string tableName, string field) { string s = "select Max({0}) from {1}"; s = string.Format(s, field, tableName); int i = Convert.ToInt32(SqlHelper3.ExecuteScalar(connectionString, CommandType.Text, s) == DBNull.Value ? "0" : SqlHelper3.ExecuteScalar(connectionString, CommandType.Text, s)); return(i); }
public static int GetRecordCount(string connectionString, string tablename, string where) { string s = "select count(*) from {0} "; s = string.Format(s, tablename); if (!string.IsNullOrEmpty(where)) { s += " where " + where; } return(Convert.ToInt32(SqlHelper3.ExecuteScalar(connectionString, CommandType.Text, s))); }
public static object ExecuteScalar(string connectionString, string sql, params SqlParameter[] para) { return(SqlHelper3.ExecuteScalar(connectionString, CommandType.Text, sql, para)); }
public static object ExecuteScalar(string sql) { return(SqlHelper3.ExecuteScalar(connString, CommandType.Text, sql)); }