Databases Reference
In-Depth Information
VB.NET
Public Overloads Function Add(ByVal value As IDataParameter) As Integer _
Implements IDataParameterCollection.Add
Return (paramList.Add(value))
End Function
Creating the DataSetCommand Class
The command object is responsible for sending commands to the data source. This is enforced by making
the object implement the IDbCommand interface, which supplies a standard mechanism for passing in
commands to be executed against the data source as well as parameters that might be needed in the process
of executing these commands. It also defines a property that allows the developer to associate the command
with a transaction object. Your implementation is simplified in that it does not support transactions or
parameters.
In your implementation, this class is where the majority of the work is done. You need to process the
command text to know what data the user wants. You must validate that this text conforms to your
requirements, and then you need to create the internal data reference that will supply the data for the
data reader object to process. You are going to be using some of the built-in behaviors of the
System.Data.DataSet class to satisfy your needs.
To add the DataSetCommand class to the project, choose Project
Add Class from the menu. Change the
name of the class to DataSetCommand . Use the Interface Autocomplete feature to have Visual Studio cre-
ate the wrappers for the methods that you will implement. Most of the functionality that exists in this
extension will live in this class.
Variable Declarations
Since, most of our work is done in this class, it make sense that most of our code is also. First, you need
to create variables to hold your property data. This class is actually going to be a wrapper around some
of the built-in DataSet functionality, so you will need reference variables for the data set objects as well
as other variables used for text parsing and the like. In order to not be repetitive, I will discuss the variables
in more depth where they are used.
C#
// property variables
int m_commandTimeOut=0;
string m_commandText = String.Empty;
DataSetConnection m_connection;
DataSetParameterCollection m_parameters;
//dataset variables
string tableName= String.Empty;
FCLData.DataSet dataSet = null;
internal FCLData.DataView dataView = null;
// regex variables
MatchCollection kwc = null;
Search WWH ::




Custom Search