|
>The difference is that in JDBC the driver is a string: in
>.NET you have to actually code for the particular class.
No you don't (have to code). The following is completely soft-coded.
Change entries in App.Config and you move from iSeries.NET driver to
Oracle to OLEDB. And if you upcast the connection you can use
type-specific methods and properties (See the use of JobName below).
Obviously if you upcast you're responsible for making sure it's a valid
upcast, you can't case a SqlConnection to an iDB2Connection.
---Begin Code---
string sCS = ConfigurationSettings.AppSettings["ConnectionString"];
string sAssemblyName =
ConfigurationSettings.AppSettings["AssemblyName"];
string sTypeName = ConfigurationSettings.AppSettings["TypeName"];
IDbConnection cn = (IDbConnection)
AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(sAssemblyName,
sTypeName);
cn.ConnectionString = sCS;
IDbCommand cm = cn.CreateCommand();
cm.CommandText = "select fld1,fld2 from c";
cn.Open();
IDataReader dr = cm.ExecuteReader();
while (dr.Read())
{
//Do something useful
}
Console.WriteLine(((iDB2Connection) cn).JobName);
cn.Close();
---End Code---
---Begin Code---
<appSettings>
<add key="ConnectionString" value="Data Source=sol;User
ID=WaldenL;Password=secret"/>
<add key="AssemblyName" value="C:\Program Files\IBM\Client
Access\IBM.Data.DB2.iSeries.dll"/>
<add key="TypeName" value="IBM.Data.DB2.iSeries.iDB2Connection"/>
</appSettings>
---End Code---
-Walden
------------
Walden H Leverich III
Tech Software
(516) 627-3800 x11
WaldenL@xxxxxxxxxxxxxxx
http://www.TechSoftInc.com
Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.