Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Connection to Backend
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01343807
Message ID:
01344588
Views:
19
>>>>>>>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] && See No database name here
>>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.
>
>
>Thnks Borislav, I thought so! I like the second aproach better. I was looking for the DBName property on my CA, go figure! LOL i got your idea. right know I just modify the app to build the connection string and use a global connection,
>
>regards



HEY!
That is a CLASS!
You could do with it whatever you want.
Add properties, Methods, whatever you want.
Just create a BASE class for your CAs and put ALL logic there, then use THAT class for your Table CAs.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform