Represents an open connection to a database. This class cannot be inherited.
Assembly: System.Data.OracleClient (in System.Data.OracleClient.dll)
An object represents a unique connection to an Oracle database. In the case of a client/server database system, it is equivalent to a network connection to the server.
An application that creates an instance of the object can set declarative or imperative security demands that require all direct and indirect callers to have adequate permission to the code. creates security demands by using the OraclePermission object. Users can verify that their code has adequate permissions by using the OraclePermissionAttribute object. Users and administrators can also use the Code Access Security Policy Tool (Caspol.exe) to modify security policy at the machine, user, and enterprise levels. For more information, see Security in the .NET Framework.
Unlike the Connection object in the other .NET Framework data providers (SQL Server, OLE DB, and ODBC), does not support a ConnectionTimeout property. Setting a connection time-out either as a property or in the connection string has no effect, and the value returned is always zero. also does not support a Database property or a ChangeDatabase method.
If the object goes out of scope, it remains open. Therefore, you should always close objects by calling Close or Dispose, or by using the object within a Using statement. Otherwise, the garbage collection might not free them immediately. Such delays can cause errors if the maximum number of connections is reached while a number of connections are waiting to be deleted by the garbage collector. By contrast, closing the connections by calling Close uses native resources more efficiently, enhancing scalability and improving overall application performance. To ensure that connections are always closed, open the connection inside of a Using block.
To deploy high-performance applications, you often need to use connection pooling. However, when you use the .NET Framework Data Provider for Oracle, you do not need to enable connection pooling because the provider manages this automatically.
The following example creates an OracleCommand and an . The is opened and set as the OracleCommand::Connection property. The example then calls ExecuteNonQuery, and closes the connection. To accomplish this, the ExecuteNonQuery is passed a connection string and a query string that is an SQL INSERT statement.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.