public static IDbConnection GetDbConn(string dbname, MDataBaseType type)
        {
            IDbConnection conn = null;
            string connstr = GetBDConnString(dbname);
            switch (type)
            {
                case MDataBaseType.MYSQL:
                    conn = new MySqlConnection(connstr);
                    if (conn.State != ConnectionState.Open)
                    {
                        conn.Open();
                    }

                    break;
                case MDataBaseType.SQLSERVER:
                    conn = new SqlConnection(connstr);
                    break;
                case MDataBaseType.DB2:
                    conn = new DB2Connection(connstr);
                    break;
                case MDataBaseType.UNKNOW:
                    throw new Exception("未知数据库类型,创建数据库链接失败");
            }

            return conn;
        }
Example #2
0
        public static IDbConnection GetDbConn(string dbname, MDataBaseType type)
        {
            IDbConnection conn    = null;
            string        connstr = GetBDConnString(dbname);

            switch (type)
            {
            case MDataBaseType.MYSQL:
                conn = new MySqlConnection(connstr);
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                break;

            case MDataBaseType.SQLSERVER:
                conn = new SqlConnection(connstr);
                break;

            case MDataBaseType.DB2:
                conn = new DB2Connection(connstr);
                break;

            case MDataBaseType.UNKNOW:
                throw new Exception("未知数据库类型,创建数据库链接失败");
            }

            return(conn);
        }
Example #3
0
        public static IGetSchema GetSchemaDAO(MDataBaseType dbType, MDBAccessType accessType)
        {
            switch (dbType)
            {
                case MDataBaseType.DB2:
                    return new DGetSchema();
            }

            throw new Exception(string.Format("未实现的IGetSchema接口:数据库类型:{0},数据库访问类型:{1}", dbType.ToString(), accessType.ToString()));
        }
Example #4
0
        /// <summary>
        /// Gets the pager query DAO.
        /// </summary>
        /// <param name="dbtype">The dbtype.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception"></exception>
        public static IPagerQuery GetPagerQueryDAO(MDataBaseType dbtype)
        {
            switch (dbtype)
            {
                case MDataBaseType.MYSQL:
                    return new DPagerQuery();
            }

            throw new Exception(string.Format("未实现的IPagerQuery接口:数据库类型:{0}", dbtype.ToString()));
        }
Example #5
0
        /// <summary>
        /// Gets the pager query DAO.
        /// </summary>
        /// <param name="dbtype">The dbtype.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception"></exception>
        public static IPagerQuery GetPagerQueryDAO(MDataBaseType dbtype)
        {
            switch (dbtype)
            {
            case MDataBaseType.MYSQL:
                return(new DPagerQuery());
            }

            throw new Exception(string.Format("未实现的IPagerQuery接口:数据库类型:{0}", dbtype.ToString()));
        }
Example #6
0
        public static IGenerator GetGeneratorSQLDAL(MDataBaseType type)
        {
            switch (type)
            {
                case MDataBaseType.MySQL:
                    return new MySQLGeneratoDAO();

                default:
                    throw new Exception(string.Format("数据库类型:{0},并没有实现", type.ToString()));
            }
        }
Example #7
0
        public static IGetSchema GetSchemaDAO(MDataBaseType dbType, MDBAccessType accessType)
        {
            switch (dbType)
            {
            case MDataBaseType.DB2:
                return(new DGetSchema());

            case MDataBaseType.SQLSERVER:
                return(new Help.DBAccessLayer.SQLServer.DGetSchema());
            }

            throw new Exception(string.Format("未实现的IGetSchema接口:数据库类型:{0},数据库访问类型:{1}", dbType.ToString(), accessType.ToString()));
        }
Example #8
0
        public static IGenerator GetGeneratorSQLDAL(MDataBaseType type)
        {
            switch (type)
            {
            case MDataBaseType.MYSQL:
                return(new DGeneratoDAO());

            case MDataBaseType.SQLSERVER:
                return(new SQLServer.DGenerator());

            default:
                throw new Exception(string.Format("数据库类型:{0},并没有实现", type.ToString()));
            }
        }