| | |
VB: Connect to Access database via ODBC datasource name
![]() |
What version of VB are you using? And, what is DBEngine declared as?
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
0
#3 Jan 19th, 2003
dont know much about VB @ all but let me ask u a coupla ???...
what db are u trying to access the Access DB from?
does it support ODBC via VB directly, or do you need connection services, managers &/or drivers?
is it necessary to establish a connection authorization from your destination db to your external source (ODBC) db PRIOR to attempting connection?
i come from the Lotus Notes/Domino world, whereby the answers to all of the above is a resounding YES, but i do not know if that is universally true.
what db are u trying to access the Access DB from?
does it support ODBC via VB directly, or do you need connection services, managers &/or drivers?
is it necessary to establish a connection authorization from your destination db to your external source (ODBC) db PRIOR to attempting connection?
i come from the Lotus Notes/Domino world, whereby the answers to all of the above is a resounding YES, but i do not know if that is universally true.
0
#4 Jan 19th, 2003
Just wanna check up on something ...
Personally, I've never connected to a database via ODBC. However, just wanna check:
You say you used the command
Set db = DBEngine.Workspaces(0).OpenDatabase("dbsourcename", ,"DSN=dbsourcename;UID=MyUID;PWD=Mypassw")
to connect to the database. You *DID* replace the items in bold with your own variables, right? Just making sure!
Also ... one more thing ... between dbsourcename and DSN=, you have two commas. Is it supposed to be like that. You use a ; to separate all of the other parameters.
Just a lil syntax check you may wanna look at!
Personally, I've never connected to a database via ODBC. However, just wanna check:
You say you used the command
Set db = DBEngine.Workspaces(0).OpenDatabase("dbsourcename", ,"DSN=dbsourcename;UID=MyUID;PWD=Mypassw")
to connect to the database. You *DID* replace the items in bold with your own variables, right? Just making sure!

Also ... one more thing ... between dbsourcename and DSN=, you have two commas. Is it supposed to be like that. You use a ; to separate all of the other parameters.
Just a lil syntax check you may wanna look at!
0
#5 Jan 19th, 2003
Dani -
Thats wrong :-P. When you use a DSN, you do not need to fill in any other information. The DSN stores everything for you.
Also you seperate connnectionstring items with a ;
Thats wrong :-P. When you use a DSN, you do not need to fill in any other information. The DSN stores everything for you.
Also you seperate connnectionstring items with a ;
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
0
#6 Jan 19th, 2003
What I'm saying is this is the code that ChristinaOrchid used. It doesn't matter whether they're using extraneous info, etc. It might be a syntax error (e.g. they used a comma instead of a semi-colon.)
You just said you don't need to fill in any other info? Well they did (as you can see). Maybe that's the problem?
Just trying to troubleshoot the code THEY used from a syntax error standpoint.
You just said you don't need to fill in any other info? Well they did (as you can see). Maybe that's the problem?
Just trying to troubleshoot the code THEY used from a syntax error standpoint.
0
#7 Jan 19th, 2003
If your using VB.NET or C#.NET the following link is your end-all resource!
http://www.connectionstrings.com/
The following is if you're using VB.NET:
Access
ODBC
Standard Security:
Workgroup:
OLEDB, OleDbConnection (.NET)
Standard security:
Workgroup (system database):
With password:
DSN
DSN:
File DSN:
http://www.connectionstrings.com/
The following is if you're using VB.NET:
Access
ODBC
Standard Security:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
"Driver={Microsoft Access Driver (*.mdb)};Dbq=\somepath\mydb.mdb;Uid=Admin;Pwd=asdasd;"
Workgroup:
•
•
•
•
"Driver={Microsoft Access Driver (*.mdb)};Dbq=\somepath\mydb.mdb;SystemDB=\somepath\mydb.mdw;"
OLEDB, OleDbConnection (.NET)
Standard security:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=asdasd;"
Workgroup (system database):
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:System Database=system.mdw;","admin", ""
With password:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;","admin", ""
DSN
DSN:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
"DSN=myDsn;Uid=username;Pwd=;"
File DSN:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
"FILEDSN=c:\myData.dsn;Uid=username;Pwd=;"
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
•
•
Join Date: Jan 2003
Posts: 5
Reputation:
Solved Threads: 0
0
#8 Jan 20th, 2003
Hi All,
I will try to describe more clearly my problem:
I am working on my Excel workbook and I create a button trying to connect to Access database or Oracle database that I already created datasource name for those 2 database in ODBC window. However, when I write the code like this:
Set db = DBEngine.Workspaces(0).OpenDatabase("", , , "ODBC;")
this open an ODBC window and let me select a datasource name. When I select an Oracle datasource name, the connection is successful. However, when I select an Access datasource name, I got the message error <<You cannot use ODBC to import from, export to, or link an external Microsoft Jet or ISAM database table to your database. (Error 3423)>>
So, My first question is why I cannot access to Access database??
Second, I trie to test to connect to Oracle/Access database by passing the datasource name as follow:
Set db = DBEngine.Workspaces(0).OpenDatabase("Oracle7", , , "DSN=Oracle7; DBQ=sqn2_mars; UID=MyuserId; PWD=Mypwd"), the effect is the same as if my first example on the top.
Hi Tekmaven,
I did'nt declare my DbEngine. As I know DbEngine is the top level object in the DAO and we can use without declaring it.
Hi aeinstein,
My problem is when I trie to connect to Access database.
Hi cscgal,
I have compied my code and there is no error syntaxe that's why it open the ODBC window and let me select my datasource name.
Thank All for your response, I am looking for all your new response days and days :p)
ChristinaOrchid.
I will try to describe more clearly my problem:
I am working on my Excel workbook and I create a button trying to connect to Access database or Oracle database that I already created datasource name for those 2 database in ODBC window. However, when I write the code like this:
Set db = DBEngine.Workspaces(0).OpenDatabase("", , , "ODBC;")
this open an ODBC window and let me select a datasource name. When I select an Oracle datasource name, the connection is successful. However, when I select an Access datasource name, I got the message error <<You cannot use ODBC to import from, export to, or link an external Microsoft Jet or ISAM database table to your database. (Error 3423)>>
So, My first question is why I cannot access to Access database??
Second, I trie to test to connect to Oracle/Access database by passing the datasource name as follow:
Set db = DBEngine.Workspaces(0).OpenDatabase("Oracle7", , , "DSN=Oracle7; DBQ=sqn2_mars; UID=MyuserId; PWD=Mypwd"), the effect is the same as if my first example on the top.
Hi Tekmaven,
I did'nt declare my DbEngine. As I know DbEngine is the top level object in the DAO and we can use without declaring it.
Hi aeinstein,
My problem is when I trie to connect to Access database.
Hi cscgal,
I have compied my code and there is no error syntaxe that's why it open the ODBC window and let me select my datasource name.
Thank All for your response, I am looking for all your new response days and days :p)
ChristinaOrchid.
0
#10 Jan 20th, 2003
Huh? Are you tring to import data from a table? If you are, just selecet File->Open and change the file type to "Acess Databases." You will recieve a wizard that will automatticly import the data for you!
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
![]() |
Similar Threads
- how to connect ms access database to html webpage (JavaScript / DHTML / AJAX)
- Connect to access database on a shared folder (C#)
- Connect Access Database to a Website (MS Access and FileMaker Pro)
- connect to access database over network (C#)
- Writing to an Access Database (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: crystal report 8 designing during runtime!!!
- Next Thread: Using C# library in vba
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic birth bmp calculator cd cells.find click client code connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges objectinsert open oracle password program prompt range-objects readfile reading remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web windows







