Creating C# Classes - KISS Methodology

in Command

Classes offer a way to encapsulate related functions in such a manner as to have them available at their least common functionality locally as well as remotely.

As an example we will examine object linking and embedding database (OleDB) management and utilization.

The namespace is a unique mechanism to house and organize methods and other components of a particular class. The namespace should have structure of cid_fmaid.appname. The cid is the company id. The underscore character is unchanged the famid is the family id of the application.

The appname is the application name the namespace is applicable to. When we expand the acronym to its fullest usability we yield BCS_Access.bex. The bex in this example refers to the Book Exchange application. By using this naming convention the technician is informed about the overall function of the aforementioned class. Properties are intentionally omitted from this exercise. Properties are only used when the provided mechanisms (passed parameters and returned types) cease to satisfy the functional requirements.

The first consideration is to establish a connection with the data base management system (DBMS).

OpenDB establishes the connection string and instantiates in instance of OleDB for subsequent processing.

CreateCmd creates a handle for parsing SQL commands.

SetSql attaches text commands for the command processor to handle.

ClearParams resets the parameters collection used by the command.

CreateParm instructs the command processor to instantiates a new parameter in the parameters collection used by the command.

ExecSql tells the command processor to execute the command with parameters that have been presented. This level of command does not return result sets. Instead it performs create, read, update and delete functions which may affect one or many records in the associated table.

LoadReader provides all necessary communications to handle result set yielded from the associated query. This result or record set is processed on a by record basis. Our class provides the user with a handle containing all the records in the result set.

CloseReader terminates reader processing and closes the result set reader.

CloseDB terminates the instantiated instance of OleDB.

These are the core methods use for handling idiosyncrasies of OleDB utilization for our designed C # class. Other methods are employed which bundle the core methods in sequence to achieve an overall desired effect.

Author Box
Arch Brooks has 1 articles online

Article Source:

Add New Comment

Creating C# Classes - KISS Methodology

Log in or Create Account to post a comment.
Security Code: Captcha Image Change Image
This article was published on 2010/03/31