ClassArchitect Usage Notes
ClassArchitect is a useful program written in VB which will generate fully functional Visual Basic Classes for your COM objects with a whole load of standard methods, properties and attributes (including Audit code).
This may sound simple, but bear in mind that the methods generated handle all your ADO interfacing and that all methods that cause database modifications also support full auditing of who did what and when.
Note: The code generated is simply the VB source code of a VB Class and needs to be included into your project as a proper Class. It also has dependencies on the CommonADO code which is also provided on this site.
The generated Class will contain all the required attributes and properties and the following methods:Description
GetAttributes
ValidateforDB
(left empty since it is app specific)
SelectFromDB
InsertIntoDB
DeleteFromDB
UpdateInDB
SelectCollectionFromDB
BuildOptionList
BuildHTMLTable
BuildJScriptArrays
Class_Initialize
You may then modify the resultant code to cater for any extra functionality.
To make a class, all you need to do is create a simple text file in the following format:
class:,classname,tablename
keys:,attribute name, column name, datatype, generate key(y=auto,n=not auto)
lookup:,attribute name, column name, datatype
attr:,attribute name, column
name, datatype
(repeated attr lines for each attribute not already specified
as a key or lookup)
e.g
class:,Product,db_product
keys:,ProductKey,prod_id,long,Y
lookup:,ProdName,prod_name,string
attr:,ProdDesc,prod_description,string
attr:,TimeStamp,prod_modified,datetime
Where:
CLASS identifies
the name of the class and the corresponding database table
KEYS identifies
the name of the attribute, column and type of the underlying key for the class.
Can be Integer or string. If the generate key attribute is set to Y and the key
is Integer, then a key will be auto generated in the insertintodb method (using
MAX + 1 from database table)
LOOKUP identifies the textual lookup
attribute, column and type (not needed if you have a already specified a textual
key)
ATTR specifies your class attributes, corresponding column names
and types (Note: you do not need to re-specify KEY or LOOKUP lines)
DataType Can
be any of String, Long, Date or DateTime
You can run ClassArchitect from the command line as follows:
classarchitect mysimplefile
If you run the program without a filename a simple popup will displayed where you can enter the name of your class definition file or browse your way to it.
A new file named classname.cls will be created which can then be added to your existing COM project. Note: It is assumed that your COM project follows the standards required by the CommonADO code. See its usage notes for details.
Example Output:
If ClassArchitect is invoked against the following very simple small test file:
class:,Product,db_product
keys:,ProductKey,prod_id,long,Y
lookup:,ProdName,prod_name,string
attr:,ProdDesc,prod_description,string
attr:,TimeStamp,prod_modified,datetime
You will get the following perfectly formed class
Option Explicit