/// <summary> /// 获取数据库连接字符串 /// </summary> /// <param name="dbParam">数据库连接参数</param> /// <returns></returns> public static string GetConnectionString(DatabaseParam dbParam) { string strConn = string.Empty; switch (dbParam.DBType) { case Defines.VCT_DBTYPE_MYSQL: strConn = string.Format("Server={0};Port={1};Database={2};Uid={3};Pwd={4}" , dbParam.DBServer , dbParam.DBPort , dbParam.DBName , dbParam.LoginUser , dbParam.LoginPassword); break; case Defines.VCT_DBTYPE_MSSQL: strConn = string.Format("Data Source={0},{1};Initial Catalog={2};User Id={3};Password={4}" , dbParam.DBServer , dbParam.DBPort , dbParam.DBName , dbParam.LoginUser , dbParam.LoginPassword); break; case Defines.VCT_DBTYPE_ORACLE: strConn = string.Format("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={0})(PORT={1})))(CONNECT_DATA=(SERVICE_NAME={2})));User ID={3};Password={4};" , dbParam.DBServer , dbParam.DBPort , dbParam.DBName , dbParam.LoginUser , dbParam.LoginPassword); break; } return(strConn); }
/// <summary> /// 使用指定的数据库连接参数创建一个DBAccessHelper实例 /// </summary> /// <param name="dbParam"></param> public DBAccessHelper(DatabaseParam dbParam) : this() { mDBParam = dbParam; }