Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto ODBC Create & Connect ?

Status
Not open for further replies.

diarmaid

Programmer
Jun 27, 2003
34
IE
Ref: thread1252-1087450

I have multiple users accessing an Access.MDB via remote view in my Foxpro.DBC - work great, except I keep having to explain how to create ODBC connections to users :-(

Is it possible to check if a connect exists on a workstation, if not create it (knowing where the .MDB file is) ?

I've been trying various things like:

CREATE CONNECTION MyStockManager CONNSTRING SQLSTRINGCONNECT("Driver={Microsoft Access Driver (*.mdb)};Dbq="+(lcMDBFile)+";Uid=Admin;Pwd=;")

I want to avoid users having to create this ODBC connection themselves.

Thanks!
 
Hi Diarmaid,

One option would be to use a file DSN. This is a simple text file that contains the connection string settings, with one setting per line.

Because it's just a file, you can test for its existence, create it programmatically, or distribute to your users.

In VFP, you simply pass the file to SQLCONNECT(), just as you would any other DSN.

Does that help at all?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
You might try using a command line approach such as:
Code:
ODBCCONF.EXE /a {CONFIGSYSDSN "Microsoft Access Driver (*.mdb)" DSN=YourName;DBQ=\\yourserver\share\your.mdb;Description=YourName-Database;}
{/Code]

Don't forget to add entries for username and password if applicable.

If that worked by executing it manually, then within the application I'd put in code to examine the workstation's Registry to determine if the ODBC driver existed or not.  And if not, then I'd have the application execute the code to RUN the command line and install it.

If it doesn't work for you at all then follow Mike's suggestion above - go into a workstation with a working ODBC DSN and copy it out to a .REG file.  The use that .REG file on other's workstations to install the ODBC driver.

There is a reasonably good example of a .REG file contents at another Tek-Tips forum.  You might want to look at it.
[URL unfurl="true"]http://www.tek-tips.com/viewthread.cfm?qid=125687&page=41[/URL]

Again, if you need to use username & password, be certain that your .REG file contains those values.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top