Exemplo n.º 1
0
        public DbDataAdapter makeDBA(theDatabaseType dbType, string selectQuery)
        {
            switch (dbType)
            {
            case theDatabaseType.MSSQL:
            case theDatabaseType.MDB:
            case theDatabaseType.PSQL:
            case theDatabaseType.SQLITE:
            case theDatabaseType.NONE:
            default:
                DbCommand cmd = conn.CreateCommand();
                cmd.CommandText = selectQuery;

                DbDataAdapter dba = openDBA(dbType);
                dba.SelectCommand = cmd;
                return(dba);
            }
        }
Exemplo n.º 2
0
        public DbCommandBuilder openBuilder(theDatabaseType dbType)
        {
            switch (dbType)
            {
            case theDatabaseType.MSSQL:
                return(new SqlCommandBuilder());

            case theDatabaseType.MDB:
                return(new OleDbCommandBuilder());

            case theDatabaseType.SQLITE:
                return(new SQLiteCommandBuilder());

            case theDatabaseType.PSQL:
            case theDatabaseType.NONE:
            default:
                return(new Npgsql.NpgsqlCommandBuilder());
            }
        }
Exemplo n.º 3
0
        public DbDataAdapter openDBA(theDatabaseType dbType)
        {
            switch (dbType)
            {
            case theDatabaseType.MSSQL:
                return(new SqlDataAdapter());

            case theDatabaseType.MDB:
                return(new OleDbDataAdapter());

            case theDatabaseType.SQLITE:
                return(new SQLiteDataAdapter());

            case theDatabaseType.PSQL:
            case theDatabaseType.NONE:
            default:
                return(new Npgsql.NpgsqlDataAdapter());
            }
        }
Exemplo n.º 4
0
        public DbConnection openConnection(theDatabaseType dbType, string connString)
        {
            try
            {
                switch (dbType)
                {
                case theDatabaseType.MSSQL:
                    return(new SqlConnection(connString));

                case theDatabaseType.MDB:
                    return(new OleDbConnection(connString));

                case theDatabaseType.SQLITE:
                    return(new System.Data.SQLite.SQLiteConnection(connString));

                case theDatabaseType.PSQL:
                case theDatabaseType.NONE:
                default:
                    return(new Npgsql.NpgsqlConnection(connString));
                }
            }
            catch { }
            return(null);
        }
Exemplo n.º 5
0
 public void Connect(theDatabaseType type, string connString)
 {
     myType = type;
     conn   = openConnection(myType, connString);
     Connect();
 }