473,418 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Using ODBC in Access

I have loved the quick responses that I have received using thescripts.com for a couple of my prior questions. I thought I would ask the question here as I haven't been able to get a good result from my Google searches thus far.

I am trying to use Access to read a table from another Access database and read 2 tables from an Oracle database. With these tables I will be performing some "SELECT" queries... I have no need to make any updates or adds in any of the outside tables.

I have not been able to find a good online tutorial/walkthrough for how to do this within Access. I have found some tutorials on setting up the ODBC connection in the "Administrative Tools->Data Sources (ODBC)" menu, but am not sure what to do or how to code to use the connection within Access after that. I believe that I have to define the connection, open the connection, and grab the tables within the Access and Oracle databases that I want to use... but am for sure leaving out some steps.

Please point me in the right direction. I appreciate the wisdom from the more experienced. Thanks.
Feb 27 '08 #1
17 6518
Zwoker
66
Hi,

I'm in the middle of doing something similar.

I started with all the tables I wanted from my Oracle database declared as external linked tables (using ODBC) in the table section of MS Access. That was simple, quick and easy to use, as you can treat them just as if they are a local table for reading (only) from.

But, I found that security constraints of having to give every user of the final MDE their own access to the Oracle database meant that it was better to switch to using a connection string with a unique (and encrypted) usercode/password.

Below is a summary of some of the code I use in my program. I'm using MS Access 2003. Anywhere you see an "XXXX" block I have removed a string value, to protect the innocent - You would need to replace it with the appropriate DSN value, or whatever, anyway... *grin*
And obviously some of the variables like pUsercode contain the decrypted usercode etc...


Expand|Select|Wrap|Line Numbers
  1. connStrForDB = "Provider=MSDASQL.1;Password=" & pPassword & ";Persist Security Info=False;User ID=" & pUsercode & ";Data Source=XXXX"
  2. Set connForDB = New ADODB.Connection
  3. connForDB.ConnectionString = connStrForDB
  4. connForDB.CommandTimeout = 0
  5. connForDB.CursorLocation = adUseClient
  6. connForDB.Open
  7.  
  8. SQLstring = "Select * From " & SchemaName & ".CUST;"
  9. CustRst.Open SQLstring, connForDB, adOpenStatic, adLockReadOnly
I have heavily simplied the code for readability. All my SQL strings are much more complicated, but there is no need to show them here.

If you have any questions just ask.
And anyone else that reads this that knows more about this stuff than me (I'm still learning) should feel free to offer suggestions to improve the way I do things. :)
Feb 27 '08 #2
NeoPa
32,556 Expert Mod 16PB
Another intelligent and helpful response from Zwoker. Keep it up :)

I would see if you come across the same problems they have though, before abondonning the simpler way of using linked tables. ODBC links vary considerably, so you may not suffer the same restrictions.

If you do, then Zwoker has lit up the path ahead for you nicely.
Feb 28 '08 #3
Zwoker,

Thanks for the tip. I will try to use the link table solution and then try to use this solution if I run into problems.

I am developing a tool for a client (friend) that links to outside databases. They have given me a temporary Access database that is identical to a databases on their share drive (I am not on their network). Is there a way to set up a linked table in Access that looks for a file to link to on a share drive that I do not have access to, but will be available once the tool sits on my client's network? How about the Oracle tables that I do not have access to. Will I need the client to set up anything on their Oracle server for the linked table to work correctly?

Thanks for all the help!
Feb 28 '08 #4
NeoPa
32,556 Expert Mod 16PB
With Access tables you simply put a similarly named database file in the same relative position on your PC (Use the Dos SUBST command to set up a drive of the right letter) which has tables (the ones you need to link to) with the same name and definition as the live database.
Feb 28 '08 #5
I appreciate the continued help. I am now having problems and cannot get much further without help.

I was granted access to have read access from an Oracle DB with a generic user name and password that will be used in the tool I am building in Access.

I DO NOT have Oracle set up on my laptop. I am wondering how to set up the ODBC connection using the Link Table option in Access without Oracle set up on the computer I am developing the tool on. I have tried a few things and cannot get any further:

1) Create New Link Table
2) Select ODBC Databases from the Dropdown of File Types
3) Receive a prompt for DSN
4) Select New...
5) Select "Microsoft ODBC for Oracle..."
6) Type OracleConnection for the new DSN and click Finish

I receive a error:

"The Oracle(tm) client and networking components were not found. These components are supplied by Oracle Corp and are part of the Oracle Version 7.3 (or greater) client software installation. You will be unable to use this driver until these components have been installed."

At this point I'm not sure of how to create the DSN that I need for Oracle. Is there a way for me to access these DBs if I have network access and a username and password for the read access?

I have been given the following:

1) Oracle version the tables are in: Oracle 9.2.0.6
2) TNS (not sure where to use this)
3) Username and password

Your help would be much appreciated! Thanks!
Mar 5 '08 #6
NeoPa
32,556 Expert Mod 16PB
It looks like we're getting into specific Oracle territory here (as opposed to Access). I will post a linking thread for you in the Oracle forum asking for assistance over here (Setting up Oracle ODBC Link).
Mar 5 '08 #7
Stewart Ross
2,545 Expert Mod 2GB
I appreciate the continued help. I am now having problems and cannot get much further without help.

I was granted access to have read access from an Oracle DB with a generic user name and password that will be used in the tool I am building in Access.

I DO NOT have Oracle set up on my laptop. I am wondering how to set up the ODBC connection using the Link Table option in Access without Oracle set up on the computer I am developing the tool on. I have tried a few things and cannot get any further:

1) Create New Link Table
2) Select ODBC Databases from the Dropdown of File Types
3) Receive a prompt for DSN
4) Select New...
5) Select "Microsoft ODBC for Oracle..."
6) Type OracleConnection for the new DSN and click Finish

I receive a error:

"The Oracle(tm) client and networking components were not found. These components are supplied by Oracle Corp and are part of the Oracle Version 7.3 (or greater) client software installation. You will be unable to use this driver until these components have been installed."

At this point I'm not sure of how to create the DSN that I need for Oracle. Is there a way for me to access these DBs if I have network access and a username and password for the read access?

I have been given the following:

1) Oracle version the tables are in: Oracle 9.2.0.6
2) TNS (not sure where to use this)
3) Username and password

Your help would be much appreciated! Thanks!
Hi. Until you get more specific help from the Oracle experts via Neo's post in that forum checkout Oracle InstantClient. It's an ODBC driver that does not require an installation of Oracle itself on the client PC. The following link takes you to the Oracle page describing the product:
http://www.oracle.com/technology/tec...ent/index.html

The TNS you refer to is a small script which identifies the source server and service name. You don't need to use a TNS script with Instantclient, but Instantclient does need to know the server address and the service name, as well as your username and password.

InstantClient is free, although you have to register with Oracle before downloading it. You need the whole of the Win 32 install set, which is in two sets of files. Installation is basic - done through a batch file from a command line - and setup a bit of a trial, but when you get the driver set up right it is then very easy to link the Oracle tables to your Access application.

-Stewart
Mar 5 '08 #8
I have downloaded Intant Client, but am having trouble understanding their installation notes, specifically step 3:

Installation Instructions

Installation Steps:

1. Download the appropriate Instant Client packages for your platform. All installations REQUIRE the Basic or Basic Lite package.

2. Unzip the packages into a single directory such as "instantclient".

3. Set the library loading path in your environment to the directory in Step 2 ("instantclient"). On many UNIX platforms, LD_LIBRARY_PATH is the appropriate environment variable. On Windows, PATH should be used.

4. Start your application and enjoy.

I'm not sure how to install the client on my computer.
Mar 6 '08 #9
Stewart Ross
2,545 Expert Mod 2GB
I have downloaded Intant Client, but am having trouble understanding their installation notes, specifically step 3:

Installation Instructions

Installation Steps:

1. Download the appropriate Instant Client packages for your platform. All installations REQUIRE the Basic or Basic Lite package.

2. Unzip the packages into a single directory such as "instantclient".

3. Set the library loading path in your environment to the directory in Step 2 ("instantclient"). On many UNIX platforms, LD_LIBRARY_PATH is the appropriate environment variable. On Windows, PATH should be used.

4. Start your application and enjoy.

I'm not sure how to install the client on my computer.
Hi. You need to unzip all the Instantclient files into a single folder on your PC. Although it does not matter where this is, for convenience call the folder InstantClient and place it in the root of drive C: (as you have to add a reference to this folder to the PATH environment variable). To alter the PATH in XP go to Control Panel, select system, advanced, environment variables. In the list of system variables scroll to Path and select Edit. Add the folder to the Path statement. Mine is below as an example.
Expand|Select|Wrap|Line Numbers
  1. %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\WBEM;...; C:\Program Files\Intel\DMIX; c:\instantclient;c:\Program Files\Microsoft SQL Server\90\Tools\binn\
After unzipping all the files to the Instantclient folder in the root of C: install the driver. Select Start, Run, Cmd to start a DOS session, CD instantclient, then type ODBC_Install to run the installation batch file. Exit from the DOS session afterwards.

Finally, setup the ODBC driver from the Control Panel. Select Administrative Tools, Data Sources (ODBC), System DSN then Add. If the installation was correct you should see in the source list Oracle in InstantClient10_2. Once you get to this stage you are then in the hands of Instantclient itself for setting up the service-specific data.

Although this is quite an involved process it does not take long to do.

Hope this necessarily lengthy reply helps.

-Stewart
Mar 6 '08 #10
I really appreciate you walking me through that process!

Are the ODBC Drivers backwards compatible? Meaning, with the 10.2 driver work if I am working with Oracle9? Otherwise, is there an instant client for Oracle9?

Also, when I try to go through and set up the new ODBC Connection now, I get an error:

“The setup routines for the Oracle in instantclient10_2 ODBC Driver could not be loaded due to system error code 126″

I did a little research and found that I may be missing a couple of .dlls (mfc71.dll and msvcrt.dll) so I downloaded those and put them in my c:\instantclient directory. Still I receive that error. After a little more research, I see that I may need tnsnames.ora and sqlnet.ora files set up? If this is necessary, how should I go about setting these up? I created a new System Variable called TNS_ADMIN and pointed it to my c:\instantclient directory, but for that to work, I think I need the tnsnames.ora file? Not sure though.

Thanks.

***********************EDIT***********************

Ok... so I uninstalled the InstantClient and the Drivers and reinstalled all of them and it worked. So now I can get to the DNS setup screen for the Oracle ODBC Driver Configuration.

Where do I need to set up my TNS? I was given this:

XXX.CLIENTNAME.COM =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = XXXXX.CLIENTNAME.com)(PORT = ####))
)
(CONNECT_DATA =
(SERVICE_NAME = XXXXXXX.CLIENTNAME.com)
)
)

What do I need to do with this? Thanks.
Mar 6 '08 #11
Stewart Ross
2,545 Expert Mod 2GB
I really appreciate you walking me through that process!

Are the ODBC Drivers backwards compatible? Meaning, with the 10.2 driver work if I am working with Oracle9? Otherwise, is there an instant client for Oracle9?

Also, when I try to go through and set up the new ODBC Connection now, I get an error:

“The setup routines for the Oracle in instantclient10_2 ODBC Driver could not be loaded due to system error code 126″

I did a little research and found that I may be missing a couple of .dlls (mfc71.dll and msvcrt.dll) so I downloaded those and put them in my c:\instantclient directory. Still I receive that error. After a little more research, I see that I may need tnsnames.ora and sqlnet.ora files set up? If this is necessary, how should I go about setting these up? I created a new System Variable called TNS_ADMIN and pointed it to my c:\instantclient directory, but for that to work, I think I need the tnsnames.ora file? Not sure though.

Thanks.
Hi again. As far as I know Instant Client is compatible with a number of previous Oracle versions, including 9. Oracle's own forum posts should be able to confirm this.

Not sure about the DLL errors - not somethying that happened to me with either InstantClient 10.1 or 10.2.

You don't need the tnsnames.ora and sqlnet.ora files with Instant Client. I have used them in the past, located in a directory called Network or something - it was for a previous Oracle connection that was superseded by use of Instant Client. I have no tnsnames.ora file on my PC.

I'll attach a screenshot of my Instantclient folder so you can compare files.

-Stewart
Attached Images
File Type: jpg ScreenHunter_11.jpg (50.6 KB, 479 views)
Mar 6 '08 #12
I'm not sure if you saw my edits above... I reinstalled and fixed the problem I was having and can now get into the ODBC Configuration.

Now I am running into a problem with the TNS Service Name Dropdown. What do I need to use here? If you look at my edit to my last post, I have included what the DBA gave me for the TNS. I am not sure how to use this though. Thanks.
Mar 6 '08 #13
Stewart Ross
2,545 Expert Mod 2GB
Ok... so I uninstalled the InstantClient and the Drivers and reinstalled all of them and it worked. So now I can get to the DNS setup screen for the Oracle ODBC Driver Configuration.

Where do I need to set up my TNS? I was given this:

XXX.CLIENTNAME.COM =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = XXXXX.CLIENTNAME.com)(PORT = ####))
)
(CONNECT_DATA =
(SERVICE_NAME = XXXXXXX.CLIENTNAME.com)
)
)
Hi again. I'm not sure is the honest answer! I will attach a screenshot of my setup which you can compare (blacked out in places for security). The service name must match at the Oracle end, and the TNS name looks like your xxx.clientname.com. You may want to play around with these and click on the Test Connection button - it will stall for a while and timeout eventually if it can't connect.

-Stewart
Attached Images
File Type: jpg ScreenHunter_17.jpg (9.0 KB, 229 views)
Mar 6 '08 #14
I have played around with this a bit. This is the error that I receive every time (see attached screenshot... I have changed the name for security reasons, but have tried it with the actual name). If anyone can help resolve this issue, I would appreciate it very much. I feel like I am so close!
Attached Images
File Type: jpg untitled2.JPG (12.8 KB, 364 views)
File Type: jpg untitled3.JPG (24.8 KB, 493 views)
Mar 6 '08 #15
Stewart Ross
2,545 Expert Mod 2GB
I have played around with this a bit. This is the error that I receive every time (see attached screenshot... I have changed the name for security reasons, but have tried it with the actual name). If anyone can help resolve this issue, I would appreciate it very much. I feel like I am so close!
Hi again. The error message is telling you that the TNS service name is not valid. It will be some form of network server address URL like //xxx.clientname.com/, perhaps qualified by a port address as per your TNSNames script. To check out that you have a valid server address you can always try to ping the server address (using a DOS session - Start, Run Cmd) and see what happens. If it is correct you should receive a response to the ping.
-Stewart
Mar 6 '08 #16
SUCCESS!!!!

I received a response from another messageboard that fixed this.

I had to create a tnsnames.ora in the directory: c:\instantclient\oracle_home\network\admin\tnsname s.ora.

I created the tnsnames.ora file with the TNS script that I posted earlier and once this was set up, I was able to connect. Stuart, thank you so much for getting me so far along. I feel like I have learned a lot in a short amount of time about how ODBC works and how to set it up.

Case closed.
Mar 6 '08 #17
Stewart Ross
2,545 Expert Mod 2GB
SUCCESS!!!!
...
Case closed.
Well done!! The use of TNSnames.ora with InstantClient is one to remember for the future.
-Stewart
Mar 6 '08 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Access Newbie | last post by:
I'm using Access 2000 and I'm trying to create a pass-through query to append all the data from a local table to a remote table. I'm using the SQL query editor in MS Access to create the query (I...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
3
by: stueyh | last post by:
When attempting to connect to an Access 2000 DB using ADO.Net from within ASP.Net running under an impersonated local user account receiving the following error. ERROR Disk or network error....
12
by: chadlupkes | last post by:
I've been trying to create a simple (I hope) PHP application to send emails to a membership list. I have yet to successfully connect to my database to pull the names and email addresses. I'm...
2
by: SKB | last post by:
Hi, I am absolutely new to this area. I am getting the following difficulty : Access denied for user 'ODBC'@'localhost' (using password: NO) when I try the mysql command from within the...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
3
by: harsha.patibandla | last post by:
We have a webserver, Apache, hosted on Linux and we use php as the scripting language. Now, I am developing a form which will fill up a Microsoft Access database (on a Windows machine). For this...
4
by: Jayhawk | last post by:
Hello, I am trying to use a MS Access front end application to link to data tables stored in MySQL Server. I am running MySQL 5.0 Community Server, MySQL Connector/ODBC 3.51, and MS Access...
11
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction....
3
by: Suresh P | last post by:
Hi All, I tried to access the mysql database in ODBC using ip address and username/password. It returns, "cannot connect to MySQL server on IP ADDRESS(10060)". This could be related to Firewall...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.