Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting Database Property for form level?
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01135422
Message ID:
01135579
Views:
30
Hi Cecil,

There is way of course.
***SomeWhere at begin 
public oData
oData=createobject('redirect_dataenvironment')
oData.cRoot='E:\ProdData'


**Then in each form DE.beforeOpenTables you simply call
oData.form_de(this) &&passing entire DE object as parameter

*And tables will be all correctly open.


define class redirect_dataenvironment as custom
cRoot=''

    procedure get_database
        lparameters cDatabaseName

        do case 

            case upper(cDatabaseName)='PRODSCHD.DBC'
            return this.cRoot + '\data\ProdSchd.dbc'

            case upper(cDatabaseName)='SOMEOTHER.DBC'
            return this.cRoot + '\otherdata\SOMEOTHER.DBC'
             
            .

            .

        endcase  


    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))
                if !file(oDataEnvironment.&arr_obj(i) .database)
                    messagebox('['+oDataEnvironment.&arr_obj(i) .database+']'+chr(13)+;
                        'Not found - Check Your blah..blah')
                endif
            endif
        endfor


enddefine
This provide you with ;

1. Possibility to use multiple DBC's easily.
2. No need for setting paths to data.
3. Possibility to easily relocate production databases by
changing one global property

Or you can completely redo get_database method of this object
which returns database paths. I put it here as simple as possible
with do case but can be any kind of path construction/returning.

This will work Provided that:
1. Tables are indeed at their place.
2. That they are stored in the same folder as DBC itself.

Free tables are not supported this way, so you will hv to make some workarround. (I don't use them - sorry)

Hope this helps you.




>I could swear that I've done this before but being over 50, maybe I've forgotten how I did this.
>
>I am trying to set the database property for the dataenvironment, but it seems that you have to do this for each cursor individually. Is there any way to do this at the DataEnvironment level, something like:
>
>xxx.Database="E:\ProdData\ProdSchd.dbc"
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform