 |
jotabe Level: Big Cheese
 Registered: 26-06-2003 Posts: 23
|
DAO connecting ODBC
Hello everybody,
I am with a terrible doubt now : someone can explain to me how can I connect my database with a ODBC connection using a DSN ?
Suppose my database is myDB.mdb (Acess 2000) and VB6) and my DSN is myDSN. I am doing like this but it isn't going right :
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase("myDB.mdb", dbDriverNoPrompt, True, "ODBC;DATABASE=myDB;UID=admin;PWD=;DSN=myDSN")
It is displaying the following message :
Run time error 3151 :
ODBC - Connection to "MyDSN" failed.
If someone have any tip I would appreciate it.
My best regards.
Jotabebr
|
|
24-02-2005 at 07:40 AM |
|
|
jotabe Level: Big Cheese
 Registered: 26-06-2003 Posts: 23
|
Re: DAO connecting ODBC
I see, my friend, thanks....but I'd like to know how to connect by DAO. I have a small project and I like to change small part of the code to access my DSN.
Any tip I'd be thankfull.
Regards.
Jotabebr
|
|
25-02-2005 at 03:55 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: DAO connecting ODBC
strConn= "ODBC;DSN=" & DatabaseName & ";UID=" & UserName
& ";PWD=" & UserPassword
set db=OpenDatabase("", False, False, strConn) |
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
25-02-2005 at 12:57 PM |
|
|
jotabe Level: Big Cheese
 Registered: 26-06-2003 Posts: 23
|
Re: DAO connecting ODBC
thanks friend...but it didn't work...I follow your example but it shows the message :
"Run-time error 3423:
You cannot use ODBC to import from, export to or link an external Microsoft Jet or ISAM database table to your database."
That is my code :
Set db = OpenDatabase("", False, False, "ODBC;DSN=mydsn;UID=admin;PWD=")
If you have some other tip I'd be thankfull.
Regards.
JotaBe
|
|
27-02-2005 at 06:01 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: DAO connecting ODBC
Its been a while since I used DAO, but it seems that this message is telling that you cant connect using ODBC and DAO/JET to access database. Is this system DSN? If yes, why dont you use DSN-less connection, which is a recommended way?
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
27-02-2005 at 11:31 PM |
|
|
jotabe Level: Big Cheese
 Registered: 26-06-2003 Posts: 23
|
Re: DAO connecting ODBC
and would you mind giving to me an example about DSN-less connection, I mean, the sintax of the command ?
thanks a lot.
|
|
01-03-2005 at 02:21 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: DAO connecting ODBC
You dont say where the database is stored? If on the another computer, share this database, and just provide a full network path to this database. Like
| Set db=opendatabase("\\server\dbPath") |
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
01-03-2005 at 04:57 PM |
|
|
jotabe Level: Big Cheese
 Registered: 26-06-2003 Posts: 23
|
Re: DAO connecting ODBC
OK...thanks...I'll try...but my DB is in my computer, I mean, "C:\myfolder\mydb.mdb".
my best regards.
|
|
02-03-2005 at 08:53 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: DAO connecting ODBC
Then just change path to your DB... Since db is usually stored in the same folder as application that is using it, you may use App.Path instead
| set db=dbengine.opendatabase(app.path & "\mydb.mdb") |
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
02-03-2005 at 11:47 AM |
|
|
jotabe Level: Big Cheese
 Registered: 26-06-2003 Posts: 23
|
Re: DAO connecting ODBC
thanks friend for the tips.
{ } ' s
jotabe
|
|
04-03-2005 at 07:09 AM |
|
|
|
|
 |
 |