Wednesday, February 13, 2008

How to use DbProviderFactory and DbConnection

Refer this

http://www.developer.com/net/net/print.php/11087_3530396_2

Example

DbProviderFactory Factory = DbProviderFactories.GetFactory("DDTek.Oracle");DbConnection Conn1 = Factory.CreateConnection();

Conn1.ConnectionString ="Host=Accounting;Port=1521;User ID=scott;Password=tiger; " + "Service Name=ORCL;Min Pool Size=50";

Conn1.Open();// Pool A is created and filled with connections to the //

minimum pool size

DbConnection Conn2 = Factory.CreateConnection();

Conn2.ConnectionString = "Host=Accounting;Port=1521;User ID=Jack;Password=quake; " + "Service Name=ORCL;Min Pool Size=100";

Conn2.Open();// Pool B is created because the connections strings differDbConnection Conn3 = Factory.CreateConnection();

Conn3.ConnectionString = "Host=Accounting;Port=1521;User ID=scott;Password=tiger; " + "Service Name=ORCL;Min Pool Size=50";Conn3.Open();//

Conn3 is assigned an existing connection that was created in // Pool A when the pool was created for Conn1