Databases Reference
In-Depth Information
VB.NET
Public Interface IDbCommand
Inherits IDisposable
Sub Cancel()
Function ExecuteReader(ByVal behavior As CommandBehavior) As IDataReader
Property CommandText() As String
Property CommandTimeout() As Integer
Property CommandType() As CommandType
Function CreateParameter() As IDataParameter
Property Parameters() As IDataParameterCollection
Property Transaction() As IDbTransaction
End Interface
Now that you have created the method wrappers and created all of the variables that you need to work,
you may begin implementing your IDbCommand methods.
Cancel Method
The Cancel method is typically used to cancel a method that has been queued . Most implementations of
data providers are multithreaded and support the issue of multiple commands against the data store.
You have only created this method to support the IDbCommand interface requirements and should
inform the developer of your lack of support by throwing a NotSupportedException .
C#
public void Cancel()
{ // not supported
throw new NotSupportedException();
}
VB.NET
Public Sub Cancel() _
Implements IDbCommand.Cancel
'not supported
Throw New NotSupportedException
End Sub
ExecuteReader Function
The ExecuteReader method returns an extension-specific reader object to the caller so that it can loop
through and read the data. The DataSetCommand object creates an instance of your custom reader object
by executing this method. A reference to your custom data reader is then returned. Your implementation
actually builds a temporary table with a schema built based on the query issued by the user. You don't
want to fill this temporary table unless the user actually requests the data, so you are checking to see if it
is a schema-only command. You are also checking to see if the user indicated that they want all of the
fields available from the data source. If that is the case, you use the default DataTable, which already
contains all of the data.
C#
public IDataReader ExecuteReader (CommandBehavior behavior)
{
if(!(behavior == CommandBehavior.SchemaOnly) && !useDefaultTable)
Search WWH ::




Custom Search