Esempio n. 1
0
 public IDbConnection getConnection()
 {
     
         if (!this.configInit)
         {
             NpgsqlEventLog.LogName = @"c:\_ekoal\LogFile.txt";
             this.configInit = true;
             this._dbType = ConfigurationManager.AppSettings.Get("db.type");
             this._connectionString = ConfigurationManager.AppSettings.Get("db.connectionString");
         }
         switch (this._dbType)
         {
             case "postgre":
                 myConnection = new NpgsqlConnection();
                 this._curDbType = db.dataBaseType.postgre;
                 break;
             case "access":
                 this._curDbType = db.dataBaseType.access;
                 break;
             case "sqlServer":
                 this._curDbType = db.dataBaseType.sqlServer;
                 break;
             case "mySql":
                 myConnection = new MySqlConnection();
                 this._curDbType = db.dataBaseType.mySql;
                 break;
             default:
                 this._curDbType = db.dataBaseType.undef;
                 break;
         }
         myConnection.ConnectionString = this._connectionString;
         myConnection.Open();
     
     return myConnection;
 }
Esempio n. 2
0
        public IDbConnection getConnection()
        {
            if (!this.configInit)
            {
                NpgsqlEventLog.LogName = @"c:\_ekoal\LogFile.txt";
                this.configInit        = true;
                this._dbType           = ConfigurationManager.AppSettings.Get("db.type");
                this._connectionString = ConfigurationManager.AppSettings.Get("db.connectionString");
            }
            switch (this._dbType)
            {
            case "postgre":
                myConnection    = new NpgsqlConnection();
                this._curDbType = db.dataBaseType.postgre;
                break;

            case "access":
                this._curDbType = db.dataBaseType.access;
                break;

            case "sqlServer":
                this._curDbType = db.dataBaseType.sqlServer;
                break;

            case "mySql":
                myConnection    = new MySqlConnection();
                this._curDbType = db.dataBaseType.mySql;
                break;

            default:
                this._curDbType = db.dataBaseType.undef;
                break;
            }
            myConnection.ConnectionString = this._connectionString;
            myConnection.Open();

            return(myConnection);
        }