Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there a way to build an ODBC connection on the fly
Message
 
 
À
02/09/2003 04:30:20
Edward Crawford
City Facilities Management
Glasgow, Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00825193
Message ID:
00825331
Vues:
15
>I want to access different Acess databases. The user will select the file using GETFILE(). I then wnat to build of ODBC conection using that path and the DSN name of "arcview". This way I can make a call to arcview with my remote views and it will address the correct database.

Very simple. First download my ODBC DSN class from http://www.mctweedle.com/downloads/odbc_dsn.zip

The code to do what you want is:
#INCLUDE ODBC.H
LOCAL llModify, lcMDBFile, lcParmString, loODBC

*!* Modify existing ODBC DSN entry. Change to .F. to create new DSN
llModify = .t.

lcMDBFile = GETFILE('MDB')
IF EMPTY(lcMDBFile) OR NOT FILE(lcMDBFile)
	RETURN
ENDIF
lcParmString = 'DSN=ArcView;DBQ=' + lcMDBFile
loODBC = NEWOBJECT('ODBC', 'ODBC.FXP')
? loODBC.CreateUserDSN(ODBC_MS_ACCESS, lcParmString, llModify)
loODBC.Release()
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform