dotConnect for Oracle Documentation
DbConnectionBase Class
Members  Example  See Also  support@devart.com
Devart.Common Namespace : DbConnectionBase Class

Represents an open connection to a server.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Data.Common.DbConnection
            Devart.Common.DbConnectionBase
               Devart.Data.Oracle.OracleConnection

Syntax

Visual Basic (Declaration) 
Public MustInherit Class DbConnectionBase 
   Inherits System.Data.Common.DbConnection
   Implements IComponentIDbConnectionIDisposable 
C# 
public abstract class DbConnectionBase : System.Data.Common.DbConnection, IComponentIDbConnectionIDisposable  

Remarks

The abstract DbConnectionBase class implements some of DbConnectionBase functionality that is DBMS-independent.

Example

The following sample demonstrates how using base classes helps to create database-independent code.
C#csharpCopy Code
public void PrintDept(DbConnectionBase myConnection) {
        DbCommandBase myCommand = (DbCommandBase)myConnection.CreateCommand();
        myCommand.CommandText = "SELECT * FROM Test.Dept";
        myConnection.Open();
        DbDataReader myReader = myCommand.ExecuteReader();
        try {
                while (myReader.Read()) {
                        Console.WriteLine(myReader.GetInt32(0) + " " + 
                                myReader.GetString(1) + " " + myReader.GetString(2));
                }
        }
        finally {
                myReader.Close();
                myConnection.Close();
        }
}
C#Visual BasicCopy Code
Public Sub PrintDept(ByVal myConnection As DbConnectionBase)
        Dim myCommand As DbCommandBase = myConnection.CreateCommand()
        myCommand.CommandText = "SELECT * FROM Test.Dept"
        myConnection.Open()
        Dim myReader As DbDataReader = myCommand.ExecuteReader()
        Try
                While myReader.Read()
                        Console.WriteLine(String.Concat(myReader.GetInt32(0), " ", _
                                myReader.GetString(1), " ", myReader.GetString(2)))
                End While
        Finally
                myReader.Close()
                myConnection.Close()
        End Try
End Sub

Requirements

Namespace: Devart.Common

Platforms:Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8, Windows 10, Windows Server 2012 family.

See Also