Accessing Oracle Databases from the NET Framework

Microsoft Data Access Components (MDAC) provides components that use ODBC and OLE DB interfaces to access Oracle databases. Although the Oracle ODBC data provider is still supported in the current release of MDAC, it is recommended that you use another .NET-supported Oracle data provider for new and upgraded applications.

By using the appropriate connection string, you can access an Oracle data source with the ODBC .NET data provider, as shown in the following code example.

Dim cn As OdbcConnection cn= New OdbcConnection ( _ "Driver = {Microsoft ODBC for Oracle};" & _ "Server=myOracleserver;uid=myuid;pwd=mypwd")

Another alternative is to use the OLE DB .NET data provider. The following code shows a sample connection string for this upgrade option.

Dim cn As OleDbConnection = New OleDbConnection( _

"Provider=MSDAORA.1;User ID=myUID;password=myPWD; " & _ "Data Source=myOracleServer;Persist Security Info=False")

The .NET Framework Data Provider for Oracle

When you upgrade a middle-tier or single-tier application that uses an Oracle database version 8.1.7 or later, it is recommended that you use the .NET Framework data provider for Oracle. This data provider allows developers to access Oracle data sources through Oracle client connectivity software and supports local and distributed transactions.

The classes that correspond to this data provider are located in the System.Data.OracleClient namespace and are contained in the System.Data.OracleClient.dll assembly. You must include this assembly as a reference to use the data provider functionality. The .NET Framework data provider for Oracle is not included in .NET Framework version 1.0. However, you can download the data provider from the Download & Code Center on MSDN.

0 0

Post a comment