dotConnect for SQLite Documentation
Devart.Common Namespace / DbCommandBase Class
Members Example

DbCommandBase Class
Represents a SQL statement to execute against a data source.
Syntax
'Declaration
 
Public MustInherit Class DbCommandBase 
   Inherits System.Data.Common.DbCommand
   Implements System.ComponentModel.IComponentSystem.Data.IDbCommandSystem.IDisposable 
 
Remarks
Abstract DbCommandBase class implements some of DbCommandBase functionality that is data source-independent.
Example
The following sample demonstrates how using base classes helps to create data source-independent code.
public void PrintDept(DbConnectionBase myConnection) {
        DbCommandBase myCommand = (DbCommandBase)myConnection.CreateCommand();
        myCommand.CommandText = "SELECT DeptNo, DName, Loc FROM Dept";
        myConnection.Open();
        DbDataReader myReader = myCommand.ExecuteReader();
        try {
                while (myReader.Read()) {
                        Console.WriteLine(myReader.GetInt32(0).ToString() + " " + 
                                myReader.GetString(1) + " " + myReader.GetString(2));
                }
        }
        finally {
                myReader.Close();
                myConnection.Close();
        }
}
Public Sub PrintDept(ByVal myConnection As DbConnectionBase)
        Dim myCommand As DbCommandBase = myConnection.CreateCommand()
        myCommand.CommandText = "SELECT DeptNo, DName, Loc FROM Dept"
        myConnection.Open()
        Dim myReader As DbDataReader = myCommand.ExecuteReader()
        Try
                While myReader.Read()
                        Console.WriteLine(String.Concat(myReader.GetInt32(0).ToString(), " ", _
                                myReader.GetString(1), " ", myReader.GetString(2)))
                End While
        Finally
                myReader.Close()
                myConnection.Close()
        End Try
End Sub
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Data.Common.DbCommand
            Devart.Common.DbCommandBase
               Devart.Data.SQLite.SQLiteCommand

See Also