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); } }
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()); } }
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()); } }
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); }
public void Connect(theDatabaseType type, string connString) { myType = type; conn = openConnection(myType, connString); Connect(); }