public string getDBType(string PID) { ExcelDataBase.Database db = DbFunction.GetDB(""); return(db.DBType.Equals(DataBaseType.ORA) ? "ORA" : "MSS"); //GS_PublicVar.Dev_LoginGS(PID); //return Convert.ToString(CommonFunction.GlobalVariable["Genersoft.BS.Public.DbType"]).Trim(); }
/// <summary> /// 获取dataset,关闭conn /// </summary> /// <param name="text">sql语句或存储过程名</param> /// <param name="type">执行类型:sql或存储过程</param> /// <param name="param">参数</param> /// <returns>DataSet类型</returns> public static DataSet ExecuteDataSet(string dbname, string text, CommandType type, DbParam[] param) { Database db = GetDB(dbname); return db.ExecuteDataSet(text, type, param); }
/// <summary> /// 获取database对象 /// </summary> /// <param name="dbname">database名称</param> /// <returns>数据库类型,MSS Ora等</returns> public static Database GetDB(string dbname) { if (string.IsNullOrEmpty(dbname)) dbname = DataBaseCache.DefDB; Database db =DataBaseCache.getCacheDB(dbname); return db; }
/// <summary> /// 获取dataset,关闭conn /// </summary> /// <param name="sql">存储过程名</param> /// <param name="param">参数</param> /// <returns></returns> public static DataSet ExecuteDataSet(string dbname, string sql, DbParam[] param) { Database db = GetDB(dbname); return db.ExecuteDataSet(sql, param); }
/// <summary> /// 获取Dataset ,关闭conn /// </summary> /// <param name="text">sql语句</param> /// <returns>DataSet类型的对象</returns> public static DataSet ExecuteDataSet(string dbname, string text) { Database db = GetDB(dbname); return db.ExecuteDataSet(text); }
/// ///返回dataset,自动创建conn 执行结束关闭conn /// #region public static DataSet ExecuteDataSet(string text) /// <summary> /// 从DataBaseCache.DefDB获取Dataset ,关闭conn /// </summary> /// <param name="text">sql语句</param> /// <returns>DataSet类型的对象</returns> public static DataSet ExecuteDataSet(string text) { Database db = GetDB(DataBaseCache.DefDB); return db.ExecuteDataSet(text); }
/// <summary> ///执行存储过程或sql的datareader,自动创建conn,自动关闭conn /// </summary> /// <param name="text">sql 或proc</param> /// <param name="type">sql 或存储过程</param> /// <param name="param">参数</param> /// <param name="callback">代理方法</param> /// <returns>object基本类型</returns> public static object ExecuteRead(string dbname, string text, CommandType type, DbParam[] param, Database.DBCallback callback) { Database db = GetDB(dbname); return db.ExecuteRead(text, type, param, callback); }
/// ///执行DataReader 返回object 需要代理调用,自动创建conn,自动关闭conn /// #region public static object ExecuteRead(string dbname,string sqltext,Genersoft.GSIDP.GSYS.Data.Database.DBCallback callback) /// <summary> /// 执行datareader,参数sql语句 和 delegate返回调用,自动创建conn,自动关闭conn /// </summary> /// <param name="sqltext">sql语句</param> /// <param name="callback"> delegate 方法</param> /// <returns>object类型,基本类型</returns> public static object ExecuteRead(string dbname, string sqltext, Database.DBCallback callback) { Database db = GetDB(dbname); return db.ExecuteRead(sqltext,callback); }
/// <summary> /// 返回Dictionary 自动创建conn,自动关闭conn /// </summary> /// <param name="sql">sql或存储过程名</param> /// <param name="type">执行类型</param> /// <param name="param">参数</param> /// <returns>dict对象</returns> public static Dictionary<string, object> ExecuteReadDict(string dbname, string sql, CommandType type, DbParam[] param) { Database db = GetDB(dbname); return db.ExecuteReadDict(sql,type, param); }
/// <summary> /// 返回Dictionary 自动创建conn,自动关闭conn /// </summary> /// <param name="sql">sql</param> /// <returns>dict对象</returns> public static Dictionary<string, object> ExecuteReadDict(string dbname, string sql) { Database db = GetDB(dbname); return db.ExecuteReadDict(sql); }
/// ///执行DataReader 返回Dictionary 自动创建conn,自动关闭conn /// #region public static Dictionary<string,object> ExecuteReadDict(string sql) /// <summary> /// 返回Dictionary 自动创建conn,自动关闭conn /// </summary> /// <param name="sql">sql</param> /// <returns>dict对象</returns> public static Dictionary<string, object> ExecuteReadDict(string sql) { Database db = GetDB(DataBaseCache.DefDB); return db.ExecuteReadDict(sql); }
/// <summary> /// 执行带参数的sql,自动创建并关闭conn /// </summary> /// <param name="dbname">数据库名</param> /// <param name="sql">sql 或 存储过程名</param> /// <param name="type">执行类型</param> /// <param name="param">参数</param> /// <returns>返回影响行数</returns> public static int ExecuteNonQuery(string dbname, string sql, CommandType type, DbParam[] param) { Database db = GetDB(dbname); return db.ExecuteNonQuery(sql, type, param); }
/// <summary> /// 获取单值的函数,自动创建conn,自动关闭conn /// </summary> /// <param name="dbname">数据库名</param> /// <param name="text">sql语句或存储过程名</param> /// <param name="type">执行类型:sql或存储过程</param> /// <param name="param">参数</param> /// <returns>object类型</returns> public static object ExecuteScalar(string dbname, string sql, CommandType type, DbParam[] param) { Database db = GetDB(dbname); return db.ExecuteScalar(sql, type, param); }
public DataSet getDataSetProc(string processID, string ProcName, string[] paramArr, string[] valueArr) { DataSet ds = new DataSet(); // Database db = DataBaseManager.GetDB(); ExcelDataBase.Database db = DbFunction.GetDB(""); try { int paramLen = 0; DbParam[] myParam = null; if (paramArr != null) { paramLen = paramArr.Length; } if (db.DBType == DataBaseType.ORA) { paramLen = paramLen + 1; } if (paramLen > 0) { myParam = new DbParam[paramLen]; } if (paramArr != null) { for (int i = 0; i < paramArr.Length; i++) { DbParam vsparam = new DbParam(); vsparam.dataType = DataType.VarChar; vsparam.paramDirct = ParameterDirection.Input; vsparam.paramName = paramArr[i]; vsparam.paramValue = valueArr[i]; vsparam.sqlType = SqlType.Proc; myParam[i] = vsparam; } } if (db.DBType == DataBaseType.ORA) { DbParam vsparam = new DbParam(); vsparam.dataType = DataType.Cursor; vsparam.paramDirct = ParameterDirection.Output; vsparam.paramName = "Re_CURSOR"; vsparam.paramValue = ""; vsparam.sqlType = SqlType.Proc; myParam[myParam.Length - 1] = vsparam; } ds = db.ExecuteDataSet(ProcName, myParam); } catch (Exception ex) { throw ex; } return(ds); }