Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a way to build an ODBC connection on the fly
Message
 
 
To
02/09/2003 04:30:20
Edward Crawford
City Facilities Management
Glasgow, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00825193
Message ID:
00825331
Views:
16
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform