>>>>>I have a question regarding CA.
>>>>>
>>>>>Right now, since I am a newbie, I am creating the CA as I need on the DE of the form, but... What if I need exactly the same CA in other form?
>>>>>
>>>>>do I have to creat it everytime I need it? is there any way to store it on the DATABASE DBC and then Add it to the DE?
>>>>
>>>>No,
>>>>You can store them as an usual class in VCX, or (as William suggested, as PRG based classes).
>>>>Then you could use them where you need.
>>>>You could create also DataEnvironment class and use them there.
>>>
>>>Ok. I just created my first CA class now I wonder: is there any way to display the dataon the CA like a browse?
>>>I now i can create a form and add code to a command button to browse the cursor, but i was thinking on something more simple like in the command window? can we?
>>
>>Sure,
>>
>>oCA = NEWOBJECT([YourCAClass],[ClassLib])
>>oCa.CursorFill()
>>BROWSE NORMAL
>>
>
>Question, How do i change the CA Database on runtime?
>
>I mean, when I am at Design Environment I point to a sample database, but when real data comes in, I have like 5 DB for 5 diferent companies on the same sql server so, I was wondering, how do the CA nows what DB to chose, it knows the table, but the DB???
>TIA
If SQL Server then just CONNECT to right DB, use the right connection string.
Imaging you have 3 DBs with the same tables in there:
Selim0001
Selim0002
Selim0003
So when you connect to SQL Server like this:
lcString = [Driver=SQL Server;Server=YourServer;DataBase=Selim0001;UID=sa;PWD=Blah]
lnHandler = SQLSTRINGCONNECT(lcString)
Your CAs will use tables from Selim0001 database, if you reconnect:
SQLDISCONNECT(lnHandler)
lcString = [Driver=SQL Server;Server=YourServer;DataBase=Selim0002;UID=sa;PWD=Blah]
lnHandler = SQLSTRINGCONNECT(lcString)
Your CAs will use tables from Selim0002 database, etc.
If you want to make them more general, you could add a property to the CA class named DBName and store there the Full "path" to
your DataBase. That way you will be free to use tables from more than one Database. Then only thing you must care is the SelectCMD:
TEXT TO this.SelectCmd NOSHOW TEXTMERGE
SELECT .....
FROM <<this.DBNAME>>TableName TableName
ENDTEXT
and you could use this:
lcString = [Driver=SQL Server;Server=YourServer;UID=salPWD=Blah]
lnHandler = SQLSTRINGCONNECT(lcString)
oCA = CREATEOBJECT([YourCA],[YourVCX])
oCA.DataSource = lnHandler
oCA.DBName = [Selim0001.dbo.]
oCA.BuildCmd()
oCA.CursorFill()
Of course you should add error handlers, custom methods etc.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.