[Mono-list] .NET version 1.1 and 2.0
Thu, 18 Jul 2002 14:25:26 -0400
On Thu, Jul 18, 2002 at 07:14:43PM +0200, Rodrigo Moya wrote:
> On Tue, 2002-07-16 at 22:18, Miguel de Icaza wrote:
> > * ADO.NET: The database guys should chime in with their
> > comments, I am not a DB person, and I am passing along what
> > people who have built these systems before told me.
> the biggest problem in ADO.NET I see myself is the impossibility of using it as
> a generic database access layer. That is, to create a connection, you have to
> know in advance the DB server/API you are going to use, which is ok for some
> cases but not for generic database access.
> What I miss is something along the way the driver manager in JDBC, which allows
> to activate a driver via an identifier:
> DriverManager dm = new DriverManager ();
> IDbConnection cnc = dm.GetConnection ("PostgreSQL");
> or something similar. This would be much better than:
> if (i_want_postgres)
> cnc = new PostgresConnection ();
> else if (i_want_sql_server)
> cnc = new SqlConnection ();
> else if (i_want_generic_but_im_not_sure_there_are_drivers_installed)
> cnc = new OleDbConnection ();
> Once you get a valid IDbConnection, you can do generic usage of the class libraries
> (using the interfaces), but to get to that point, AFAIK, you have to know in
> advance the DB server you'll be connecting to.
While I admit, in theory, that it is nice to have abstraction
as to what provider you choose, I find that in practice that is
usually not very important. If you're developing a
tool/utility/platform/application/whatever that uses a database, you are
probably going to consciously choose which database you are going to use
before you actually build the application.
Besides, it isn't all that often that your SQL is 100% portable across
all database systems anyway, so abstracting away the provider is
probably not all that useful. Again, this is just in my experience;
If you create an OleDbConnection, you can (must?) specify the DataSource/
Provider before opening the connection. Thus, you can have something
like what you said about the JDBC driver...
cnc = new OleDbConnection ("Provider=MSDAORA;DataSource=mydb;User ID=user;Password=password");
...or something like that. I don't exactly remember the OleDb
connection string format.
The way I see things with ADO.NET is you either use the SqlClient if you
are accessing MSSQL or use OleDbClient otherwise. SqlClient offers some
extra features over OleDbClient, clearly because it is developed by
Microsoft. If you want extra features for your PostgreSQL database,
then you use a provider specified to PostgreSQL. AFAIK there isn't
anything stopping you from use OleDbClient to access a MSSQL database;
you just miss out on some features (and it probably isn't as optimized
That's just my 2 cents' worth.
Tim Coleman <email@example.com> [43.28 N 80.31 W]
BMath, Honours Combinatorics and Optimization, University of Waterloo
"Under capitalism, man exploits man. Under communism, it's just the
opposite." -- J.K. Galbraith