Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursor Database property fix up code
Message
From
16/02/2005 10:29:10
 
 
To
16/02/2005 04:22:40
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00986971
Message ID:
00987446
Views:
38
Hi Srdjan,

Thank you so much for this code. This is precisely what I was looking for without having to re-invent the wheel!

Best regards,

-=Gary

>>Hi,
>>
>>Could anyone point me in the direction of some Cursor object Database path "fix-up" code?
>>
>>Thanks,
>
>Hi There
>
>Here is solution I am using from 1997 (VFP5) enabling me to confortably use
>unlimited number of databases (multiple company/year/projdata datasets)
>without any problems. It is also aplicable to reports dataenvironments.
>
>It is class object changing database property to all DE cursors at run time.
>
>At the begining, object has to be instantiated as public (e.g 'oSystem' )
>so all forms can will be able to call it.
>Then all form can call it (single line) from method DE.BeforeOpenTable passing entire DE as parameter.
>
>
>public cServerDataDir,oSystem
>oSystem=createobject('redirect_dataenvironment')
>cServerDataDir = '\\someserver\RealRunTimePath' &&Should normaly come from some ini file
>
>* Then you have to insert tiny call to this object from every form DE ;
>
>* DE.BeforeOpenTables method
>oSystem.form_de(this)
>
>
>
>And here is class object that does it.
>(You can upgrade it for more complex path constructions.)
>
>
>define class redirect_dataenvironment as custom
>
>    procedure get_database
>        lparameters cDatabaseName
>        local cDatabaseName
>
>        *** Here you build your own path construction for
>        *** multiple databases,
>        *** instead of simple one I used for my sample
>        *** with one database
>
>        return addbs(cServerDataDir) + 'tastrade.dbc'
>
>    procedure form_de
>        lparameters oDataEnvironment
>        local i,j,db_name,arr_obj(1)
>        amembers(arr_obj,oDataEnvironment,2)
>        for i = 1 to alen(arr_obj)
>            j = oDataEnvironment.&arr_obj(i) .baseclass
>            if upper(alltrim(j)) = 'CURSOR'
>                db_name=upper(justfname(allt(oDataEnvironment.&arr_obj(i) .database )))
>                oDataEnvironment.&arr_obj(i) .database=this.get_database(allt(db_name))
>            endif
>        endfor
>
>
>enddefine
>
>
>
>
>I never used free tables, so it does not covers them
>but you can provide for it easily.
>
>Hope this helps you.
>Rgds++
-=Gary
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform