Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automatically generating VCX classes?
Message
From
04/01/2001 12:07:10
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Automatically generating VCX classes?
Miscellaneous
Thread ID:
00459408
Message ID:
00459408
Views:
50
Apologies in advance for Long Introductory: As some of you know, I have been getting my feet wet with ADO data access, I have created a VFP base wrapper class for my data objects, and plan to create individual classes for each table in my SQL 7 database, with essentially matching properties for the underlying table fields.

I created one of these to test it, and liked it, so I thought to do the other 40 or so a bit quicker.

I had seen a tool called DB2COM that created class definitions in a VB project to match a SQL 7 database, so I decided to write my own for VFP class generation.

I wrote a prg that opens the ADO connection schema information for the target database and reads the table information out of it to automatically generate class definition code into another program file for each table, with a parent class of my earlier defined dataobj.

This worked wonderfully, essentially generating a set of class definitions in a prg that could be used with SET PROCEDURE.
Example auto-generated Class:
*|*Programmatically defined class definition-Asset
*|* Jim Newsom 01/04/01

DEFINE CLASS Asset AS dataobj

Name = "Asset"
TableName = "Asset"
ID = 0
Number = " "
Description = " "
Active = .F.
PropertyManagerID = 0
ClientId = 0
ClientPropertyTypeId = 0


Procedure Setvalues
*|* Method Setvalues
With this 
.ID = .myrecordset.Fields("ID").Value
.Number = .myrecordset.Fields("Number").Value
.Description = .myrecordset.Fields("Description").Value
.Active = .myrecordset.Fields("Active").Value
.PropertyManagerID = .myrecordset.Fields("PropertyManagerID").Value
.ClientId = .myrecordset.Fields("ClientId").Value
.ClientPropertyTypeId = .myrecordset.Fields("ClientPropertyTypeId").Value
EndWith 
EndProc


Procedure Update
*|* Method Update
With this 
.myrecordset.Fields("Number").Value = .Number
.myrecordset.Fields("Description").Value = .Description
.myrecordset.Fields("Active").Value = .Active
.myrecordset.Fields("PropertyManagerID").Value = .PropertyManagerID
.myrecordset.Fields("ClientId").Value = .ClientId
.myrecordset.Fields("ClientPropertyTypeId").Value = .ClientPropertyTypeId
EndWith 
EndProc


ENDDEFINE
I was actually wanting to put these into a VCX, but could not find a way to get them in there :) I then wrote a 2nd prg to instantiate each class and then invoke the SaveAsClass method to put it into the VCX I chose for this.

They went in there, but with themselves as the parent class, so the method code and properties could not be seen through the class designer. *sigh*

Any ideas as to how to get programmatically generated class definitions into a VCX?

All help is greatly appreciated!
Jim Newsom
IT Director, ICG Inc.
Next
Reply
Map
View

Click here to load this message in the networking platform