Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Tip on how to fix database path in Dataenvironment
Message
 
À
03/07/1997 11:51:23
Gino Miceli
Lan Professionals, Inc.
Bay Shore, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00038538
Message ID:
00038723
Vues:
32
>Many of you had been concerned with the Database property which is read-only at design time... the end result of this is that people with two copies of their dataset (one for development and one for production), even across a network, will have the app look at the original development copy of the dataset..bad indeed!
>
>The best solution I could come up with is the hardcode the following into the BeforeOpenTables() event of the DE of each form:
>
>this.Cursor1.Database = "..\Data\Main.dbc"
>this.Cursor2.Database = "..\Data\Main.dbc"
> ... etc.
>
>This seems to work very well, even if you move your distribution directory!

I needed to have a common set of forms and reports that needed to be added to multiple applications to support common lookup tables that our applications have in common. After I got tired of mofifying them each time they were added to a new project, I came up wih this solution. I added a method to my application class that adjusts the database property or cursor source. I simply call this method from the BeforeOpenTables event of the DataEnvironment and it loops through all cursors and fixes them.

* SetDEDatabase
LPARAMETERS toDataEnvironment && DataEnvironment reference

LOCAL lcDataDir && Appplications data directory
LOCAL laMembers[1] && DE members array
LOCAL lnObjectCount && Number of objects in DE
LOCAL lnI && Loop index
LOCAL lcObjectName && Object name string
LOCAL lcTableName && Name of free table
LOCAL lcCursorSource && Cursorsource property of cursor

lcDataDir = SET("DEFAULT")+LEFT(CURDIR(),RAT("\",CURDIR(),2)) + "Data\"
lnObjectCount = AMEMBERS(laMembers, toDataEnvironment, 2)
FOR lnI = 1 to lnObjectCount
lcObjectName = laMembers[lnI]
IF UPPER(toDataEnvironment.&lcObjectName..BaseClass) = "CURSOR"
IF NOT EMPTY(toDataEnvironment.&lcObjectName..Database)
* Bound table - Update Database property
toDataEnvironment.&lcObjectName..Database = ;
lcDataDir + oApp.cDatabase + ".DBC"
ELSE
* Free Table - Update CursorSource property
lcCursorSource = toDataEnvironment.&lcObjectName..CursorSource
lcTableName = SUBSTR(lcCursorSource, RAT("\", lcCursorSource)+1)
toDataEnvironment.&lcObjectName..CursorSource = ;
lcDataDir + lcTableName
ENDIF
ENDIF
ENDFOR


Steve Ruhl
Citicorp - National Technology Division
sruhl@cyberjunction.net HOME
steven.ruhl@citicorp.com WORK
Steve Ruhl
CitiMortgage, Inc.
steven.ruhl@citibank.com Office
Steve@steven-ruhl.com Home
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform