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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DNSless (dns-less) connection to an MS Access Database 1

Status
Not open for further replies.

humour

Programmer
Nov 24, 2003
87
0
0

Has someone succesfully created a dsn-less connection to an MS Access Database.

If so a code sample would be much appreciated.

If not Access than any other ODBC database.
 
I have not tried to make a DSN-less connection to an MS Access database, but following is a sample of some code I use to make a DSN-less connection to an ASA database.

String ls_connectstring

SQLCA.DBMS = "ODBC"
ls_connectstring = "Driver=Adaptive Server Anywhere 7.0;" + &
"UID=dba;PWD=sql;" + &
"DBF=C:\Project\Data\mydata.db;" + &
"Agent=Engine"
SQLCA.DBParm = "ConnectString='" + ls_connectstring + "'"
CONNECT USING SQLCA;

To connect to an MS Access database, you will need to change the Driver name to the MS Access ODBC driver name on your PC. To find the proper driver name, open the ODBC Administrator and select the Drivers tab. Look in the list for one that says something like "MS Access Driver" or "Microsoft Access Driver". Use the driver name exactly as it appears in the list (including any suffix, like "(*.mdb)" that may appear in the name.)

As I said, the above worked for ASA, but there may be other parameters that you will need to add to the connectstring for MS Access. Check the MS Access documentation for any required connectstring parameters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top