Databases Reference
In-Depth Information
Private keyWordCount As Integer = 0
Private filtering As Boolean = False
Private sorting As Boolean = False
Private useDefaultTable As Boolean = False
Constructors
You want the users of your processing extension to be forced to create the
Command
object either through the
CreateCommand
method of the
IDbConnection
interface or by passing in a valid
DataSetConnection
object as a parameter. The purpose of this is to ensure that you have access to the underlying
DataSet
object
created and parsed in the connection process. This can be done by deleting or not providing an empty
default constructor. This prevents the developer from creating the
DataSetCommand
object without the
correct initialization. In the constructor, you want to get a reference to the
DataSet
that you opened from
the file system in your connection object.
C#
internal DataSetCommand(DataSetConnection conn)
{
this.m_connection = conn;
this.dataSet = this.m_connection.dataSet;
this.m_parameters = new DataSetParameterCollection();
}
VB.NET
Friend Sub New(ByVal conn As DataSetConnection)
Me.m_connection = conn
Me.dataSet = Me.m_connection.dataSet
Me.m_parameters = New DataSetParameterCollection
End Sub
Implementing IDbCommand
The required interface for all
Command
objects is called
IDbCommand
. It consists of methods that allow the
developer to pass commands and parameters to the
Command
object. The most interesting method in our
implementation is the
CommandText
method where you will parse the command string provided by the
user and return the appropriate data.
C#
public interface IDbCommand : IDisposable
{
void Cancel();
IDataReader ExecuteReader(CommandBehavior behavior);
string CommandText { get; set; }
int CommandTimeout { get; set; }
CommandType CommandType { get; set; }
IDataParameter CreateParameter();
IDataParameterCollection Parameters { get; }
IDbTransaction Transaction { get; set; }
}
Search WWH ::
Custom Search