Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change DBC during Application Run
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00156044
Message ID:
00156288
Vues:
42
>Here's the code I use to handle the situation where a user installs to a different directory than the one on which I created the app. It's a .prg to which you pass a dataenvironment. It sets the Database property of all cursors in the DE to the current directory plus \Data, and opens that database. It should be modifiable for your needs.
>
>* changes cursors' Database property to current directory + \Data
>* opens the database
>lparameters toDE
>
>Assert Type("toDE.Name") == 'C'
>if !(Type("toDE.Name") == 'C')
> return
>endif
>Assert Upper(toDE.Class) == Upper("DataEnvironment")
>if !(Upper(toDE.Class) == Upper("DataEnvironment"))
> return
>endif
>
>* get all the cursors in the Data Environment
>local laCursors[1]
>AMembers(m.laCursors, toDE, 1)
>
>* iterate through each cursor
>local llFirst
>llFirst = .T.
>local ln
>for ln = 1 to ALen(laCursors, 1)
> * skip non-objects
> if !laCursors[ln, 2] == "Object"
> loop
> endif
>
> * get the object name
> local lcObject
> lcObject = "toDE." + laCursors[ln, 1]
>
> * change the path to the database to the current folder + \Data
> if Eval(m.lcObject + ".Class") == "Cursor"
> Local loCursor
> loCursor = Eval(m.lcObject)
> loCursor.Database = Sys(5) + Sys(2003) + "\Data\" +;
> JustFName(loCursor.Database)
>
> if llFirst
> open database (loCursor.Database)
> llFirst = .F.
> endif
> endif
>endfor

Mark,

What about this line:
***DE.BeforeOpenTables event
Thisform.SetAll("Database",cNewdbcpathname,"Cursor")
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform