Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing DBCs within an application
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00540872
Message ID:
00574183
Vues:
23
>I'm trying to figure out how to change what dbc my application points to programmatically. The DBC tables and such are the same, I just need to be able to point to one versus the other for debugging purposes.
>
>TIA

Rodney,

I know this is an old msg, but you also can consider using the below code I wrote moons ago.

DO SearchReplacePjx WITH 'old.dbc','new.dbc'

FUNCTION SearchReplacePjx
*-Searches the PJX for a str and replaces it with anohter
parameter tcSearchStr, tcReplaceStr

IF EMPTY(tcSearchStr) OR EMPTY(tcReplaceStr)
=MESSAGEBOX('Please pass a search and replacement string')
RETURN
ENDIF
CLOSE ALL
lcProjectName=GETFILE('pjx','Select a Project')
IF EMPTY(lcProjectName)
RETURN
ENDIF
IF USED('PrjName')
USE IN PrjName
ENDIF
SELECT 0
USE (lcProjectName) ALIAS PrjName

SCAN FOR !DELETED()
DO CASE
CASE TYPE = 'M' OR TYPE = 'K' OR TYPE = 'R' OR TYPE = 'V' OR TYPE = 'B'
lcName = NAME
SELECT 0
USE (lcName) ALIAS TblNAme
FOR m.i = 1 to FCOUNT()
=SearchReplace(FIELD(m.i), tcSearchStr,tcReplaceStr)
ENDFOR
USE IN TblName
CASE TYPE = 'P'
lcName = NAME
CREATE CURSOR TmpCurs (PrgFld m)
APPEND BLANK
append memo PrgFld from (lcName)
IF SearchReplace('PrgFld', tcSearchStr, tcReplaceStr) > 0
SELECT TmpCurs
Go Top
COPY MEMO PrgFld TO (lcName)
ENDIF
USE IN TmpCurs
CASE TYPE = 'd'
lcName = NAME
SELECT 0
USE (lcName) ALIAS TblNAme
*-Update remote views only for right now
*-we can write code to update the stored procedures later and anything else.
SELECT UPPER(ALLTRIM(Objectname)) as ViewName FROM TblName WHERE ObjectTYPE = 'View' ;
INTO CURSOR ViewCurs
USE IN TblName
SELECT ViewCurs
SET SAFETY OFF
OPEN DATABASE (lcName)
lcPrgName = 'Tmp.prg'
SCAN
DO GETVIEW IN Gendbc.prg with ALLTRIM(ViewCurs.ViewName), lcPrgName
CREATE CURSOR TmpCurs (PrgFld m)
APPEND BLANK
append memo PrgFld from (lcPrgName)
IF SearchReplace('PrgFld', tcSearchStr, tcReplaceStr) > 0
SELECT TmpCurs
Go Top
COPY MEMO PrgFld TO (lcPrgName)
DO (lcPrgName)
ENDIF
USE IN TmpCurs
ENDSCAN
ERASE TMP.PRG
USE IN ViewCurs
ENDCASE
SELECT PrjName
ENDSCAN
USE IN PrjName
BUILD PROJECT (lcProjectName) RECOMPILE
=MESSAGEBOX('Done')
RETURN
ENDFUNC

PROCEDURE SearchReplace
*-Replace a field with a search string with a replacement string
*-USED BY SearchReplacePjx FUNCTION
PARAMETER tcFieldName, tcSearchStr, tcReplaceStr
IF !TYPE(tcFieldName)='C' AND !TYPE(tcFieldName)='M'
RETURN 0
ENDIF
SET NOCPTRANS TO (tcFieldName)
REPLACE (tcFieldName) WITH STRTRAN(UPPER(&tcFieldName), UPPER(tcSearchStr),UPPER(tcReplaceStr));
FOR occurs(upper(tcSearchStr),upper(&tcFieldName)) > 0
SET NOCPTRANS TO
RETURN _TALLY
RETURN
Michael Garcia
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform