Click to See Complete Forum and Search --> : DSN for Jet Database
Pinky
Mar 17th, 2000, 01:56 AM
Hi,
I'm using Access 2000. I want to use a DSN name to open the database. The provider I'm using is "Microsoft.Jet.OLEDB.4.0". I'm not sure whether I can give a DSN with this provider. Can anyone please let me know if it is possible to use DSN for "Microsoft.Jet.OLEDB.4.0" and if yes, how do I do it???
Thanks in advance.
Serge
Mar 17th, 2000, 03:39 AM
There are 2 ways to do it.
First, you can create a DSN in the Control Panel (ODBC applet) and then using that DSN to connect:
Dim cn As New ADODB.Connection
cn.Open "DSN=MyDSN"
Where MyDSN is a DSN you've created.
Or you can use DNSless connection:
Dim cn As New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "C:\MyDB.mdb", "admin", ""
Assuming that C:\MyDB.mdb is your database.
Pinky
Mar 17th, 2000, 03:47 AM
I want to use a DSN to connect to the database, but if I give the provide as "Microsoft.Jet.OLEDB.4.0" and use a DSN it gives me an error. How can I use a DSN with this provider????? This is the connection I'm using, but it gives ma an error when I run it....
Cnn.Provider = "Microsoft.Jet.OLEDB.4.0"
Cnnstring = "DSN=MyData"
Cnn.Open Cnnstring
Edited by Pinky on 03-17-2000 at 04:49 PM
Glenn
Mar 17th, 2000, 03:58 AM
What is the error you are getting ?
Pinky
Mar 17th, 2000, 04:17 AM
I'm getting Run-time error '-2147467259(800004005)': Could not find the file(.mdb)
Serge
Mar 17th, 2000, 09:22 AM
Did you physically create the DSN in the control panel???
If yes, then check the path to the database you specified.
If no, then you would have to create the DSN first.
Also, if you have DSN, then you don't have to specify the Provider, DSN will take care of that (using the Microsoft Access Driver).
Clunietp
Mar 19th, 2000, 12:41 AM
I don't think that DSNs can be used with Access 2000 databases -- I've tried using a DSN with DAO 3.6 and Jet 4.0 providers and I get UNRECOGNIZED DATABASE FORMAT....MS Support says to create the DSN using the new driver versions, but I don't see where I get that option, even though I have Access 2000 installed....
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.