public static string ExecuteSql(string sql) { string retVal; using (BaseDB.BaseDataAccess baseDataAccess = new BaseDB.BaseDataAccess()) { using (BaseDB.BaseCommand cmd = new BaseDB.BaseCommand(baseDataAccess.MsConn)) { cmd.CommandText = sql; cmd.CommandType = System.Data.CommandType.Text; retVal = cmd.ExecuteScalar(); } } return(retVal); }
public static int GetMaxId(string tableName, string field) { string result = ""; using (BaseDB.BaseDataAccess baseDataAccess = new BaseDB.BaseDataAccess()) { using (BaseDB.BaseCommand cmd = new BaseDB.BaseCommand(baseDataAccess.MsConn)) { cmd.CommandText = "Select MAX(" + field + ") From " + tableName; cmd.CommandType = System.Data.CommandType.Text; result = cmd.ExecuteScalar(); if (result == "") { result = "0"; } } } return(Int32.Parse(result)); }
public static string GetFieldValue(string tableName, string criteria, string field) { string retVal; using (BaseDB.BaseDataAccess baseDataAccess = new BaseDB.BaseDataAccess()) { using (BaseDB.BaseCommand cmd = new BaseDB.BaseCommand(baseDataAccess.MsConn)) { if (string.Compare(criteria, "") != 0) { cmd.CommandText = "Select " + field + " From " + tableName + " Where " + criteria; } else { cmd.CommandText = "Select " + field + " From " + tableName; } cmd.CommandType = System.Data.CommandType.Text; retVal = cmd.ExecuteScalar(); } } return(retVal); }