/// <summary>创建连接</summary> /// <param name="dbtype">数据库类型</param> /// <param name="connectionString">连接字符串</param> /// <returns></returns> public static DbConn CreateConn(DbType dbtype, string connectionString) { DbConn cn = null; switch (dbtype) { case DbType.SQLSERVER: cn = new DbConnSql(); break; case DbType.ORACLE: cn = new DbConnOracle(); break; default: throw new Exception("该数据库类型不适合使用CreateConn,请用new创建!"); } cn.ConnString = connectionString; return cn; }
/// <summary>创建连接</summary> /// <param name="dbtype">数据库类型</param> /// <param name="ACn">已有的连接</param> /// <returns></returns> public static DbConn CreateConn(DbType dbtype, DbConnection ACn) { DbConn cn = null; switch (dbtype) { case DbType.SQLSERVER: cn = new DbConnSql(); break; case DbType.ORACLE: cn = new DbConnOracle(); break; default: throw new Exception("该数据库类型不适合使用CreateConn,请用new创建!"); } cn._conn = ACn; return(cn); }