
ADO-->Access 97 help, please.
You don't have to specify the Provider if you are using DSN. Use the
Microsoft Access Driver and set the Workgroup file in the DSN.
Then open the connection using connection string as usual (B) or use the
sample A below.
A. Setting the workgroup file in ADO property:
----Start Code ----
Set mConnection = New ADODB.Connection
With mConnection
.Provider = "Microsoft.Jet.OLEDB.3.51"
.Properties("Jet OLEDB:System database") = "d:\vb sample\dao\system.mdw"
.Open "d:\vb sample\dao\biblio.mdb", "admin", ""
End With
----End Code ----
B. Using DSN:
1. Create a DSN with Microsoft Access Driver.
2. Select your protected database. Define the System Database to your
workgroup file.
3. Open the ADO using your DSN as usual (dont forget to define the uid and
pwd).
----Start Code ----
With mConnection
.ConnectionString = "uid=admin;pwd=;DSN=nwindpass;"
.Open
End With
----End Code ----
I include a sample DSN file below. Change the SystemDB, DefaultDir and DBQ
to your objects.
-----Begin Cut-----
[ODBC]
DRIVER=Microsoft Access Driver (*.mdb)
UID=admin
UserCommitSync=Yes
Threads=3
SystemDB=D:\VB Sample\DAO\SYSTEM.MDW
SafeTransactions=0
PageTimeout=5
MaxScanRows=8
MaxBufferSize=512
ImplicitCommitSync=Yes
FIL=MS Access
DriverId=25
DefaultDir=D:\VB Sample\DAO
DBQ=D:\VB Sample\DAO\biblio.mdb
-----End Cut-----
You can see more samples in my Site.
www.geocities.com/siliconvalley/platform/7797/
Quote:
>Greetings:
>I'm having a horrible time trying to connect to an Access97 .mdb file
>from VB5, using ADO. I have set up a System DSN for the file in
>question. Whenever I run my app, it chokes with the following
>message:
>--
>Run-time error '-2147467259 (80004005)':
>[Microsoft][ODBC Driver Manager] Data source name not found and no
>default driver specified
>--
>I have shown my code below.
>Option Explicit
>Public connWS As ADODB.Connection
>Private Sub Form_Load()
> Set connWS = New ADODB.Connection
> connWS.ConnectionString =
>"Provider=MSDASQL;DSN=DSN_name;DATABASE=Clients.mdb;UID=admin;PWD="
> connWS.Open
>End Sub
>======================================================================
>|| Email address is munged. ||
>----------------------------------------------------------------------
>http://www.mcrae.ca/greek -- Greek Discussion Groups
>http://www.mcrae.ca/greek/groups.htm -- YOUR Group's Discussion Board
>http://www.mcrae.ca/greek/mission.htm -- Why we're here