Connecting to an Oracle Data Source Using ADO.NET
The .NET Framework Data Provider for Oracle provides connectivity to Oracle data sources using the OracleConnection object.
For the .NET Framework Data Provider for Oracle, the connection string format is designed to match the OLE DB Provider for Oracle (MSDAORA) connection string format as closely as possible. For more detail on the OracleConnection , see the OracleConnection Class.
Note The .NET Framework Data Provider for Oracle is not included in the .NET Framework version 1.0. If you require the .NET Framework Data Provider for Oracle and are using the .NET Framework version 1.0, you can download the .NET Framework Data Provider for Oracle at http://msdn.microsoft.com/downloads.
The following code example demonstrates how to create and open a connection to an Oracle data source.
Dim nwindConn As OracleConnection = New OracleConnection("Data Source=MyOracleServer;Integrated Security=yes;") nwindConn.Open() [C#] OracleConnection nwindConn = new OracleConnection("Data Source=MyOracleServer;Integrated Security=yes;"); nwindConn.Open();
Closing the Connection
It is recommended that you always close the Connection when you are finished using it, in order for the connection to be returned to the pool. This can be done using either the Close or Dispose methods of the Connection object. Connections that are not explicitly closed might not be added or returned to the pool. For example, a connection that has gone out of scope but that has not been explicitly closed will only be returned to the connection pool if the maximum pool size has been reached and the connection is still valid.
Note Do not call Close or Dispose on a Connection, a DataReader, or any other managed object in the Finalize method of your class. In a finalizer, only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a Finalize method in your class definition. For more information, see Programming for Garbage Collection.