I've started work on the set of objects known as... "ADO.NET Multiplexor Provider" in... http://www.go-mono.com/ado-net.html

I'd appreciate the ADO.NET team to review this (and attached files) before I commit things to CVS. I'm planning to put them under /mcs/class/Mono.Data. Please note: connection strings will in attached files will need to be updated to match your configuration.  I've done some basic testing of the code under MS.NET & Mono on Windows.

My implementation is similar to the one Gonzalo details, but a bit different in the following ways:
1) The Provider information is seperate from the connection string information. This allows the list of providers to be stored in the machine.config.
2) Provider and ProviderCollection objects are available to access the list of providers and modify them at runtime.
3) The ProviderFactory object is used to create new connections, dataadapters, etc.

Ok...now for some sample code. Creating a connection: 

// Create connection using enhanced connection string
IDbConnection conn=ProviderFactory.CreateConnection("factory=System.Data.SqlClient;server=speedy;database=pubs;uid=sa");
// Create connection specifying provider and standard connection string
IDbConnection conn=ProviderFactory.CreateConnection("System.Data.SqlClient","server=speedy;database=pubs;uid=sa"); 

// Create connection using connection string stored in app.config under <appSettings>
IDbConnection conn=ProviderFactory.CreateConnectionFromConfig("PubsConnStr");

Here's a sample app.config file showing the provider declarations along with sample connection strings:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="mono.data">
<section name="providers" type="Mono.Data.ProviderSectionHandler,Mono.Data" />
</sectionGroup>
</configSections>
	<appSettings>
<add key="PubsConnStr" value="factory=System.Data.SqlClient;server=speedy;database=pubs;uid=sa;pwd=" />
</appSettings>
	<mono.data>
<providers>
<provider name="System.Data.SqlClient" connection="System.Data.SqlClient.SqlConnection" adapter="System.Data.SqlClient.SqlDataAdapter" assembly="System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<provider name="System.Data.OleDb" connection="System.Data.OleDb.OleDbConnection" adapter="Syste! m.Data.OleDb.OleDbDataAdapter" assembly="System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<provider name="System.Data.Odbc" connection="System.Data.Odbc.OdbcConnection" adapter="System.Data.OleDb.OdbcDataAdapter" assembly="System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<provider name="Mono.Data.TdsClient" connection="Mono.Data.TdsClient.TdsConnection" adapter="Mono.Data.TdsClient.TdsDataAdapter" assembly="Mono.Data.TdsClient" />
<provider name="Mono.Data.MySql" connection="Mono.Data.MySql.MySqlConnection" adapter="Mono.Data.MySql.MySqlDataAdapter" assembly="Mono.Data.MySql" />
<provider name="Mono.Data.PostgreSqlClient" connection="Mono.Data.PostgreSqlClient.PgSqlConnection" adapter="Mono.Data.PostgreSqlClient.PgSqlDataAdapter" assembly="Mono.Data.PostgreSqlClient" />
<provider name="Mono.Data.SqliteClient" connection="Mono.Data.SqliteClient.S! qliteConnection" adapter="Mono.Data.SqliteClient.SqliteDataAdapter" assembly="Mono.Data.SqliteClient" />
<provider name="Mono.Data.SybaseClient" connection="Mono.Data.SybaseClient.SybaseConnection" adapter="Mono.Data.SybaseClient.SybaseDataAdapter" assembly="Mono.Data.SybaseClient" />
</providers>
</mono.data>
</configuration>

Alrighty..that's it!  Let me know what you guys think...
Brian

 



Internet access plans that fit your lifestyle -- join MSN. Click Here

Attachment: Mono.Data.zip
Description: Zip compressed data

Reply via email to