I can't see anywhere where you have defined the connection to the database.
http://www.connectionstrin
Main Topics
Browse All TopicsHi,
I have started to create a code to connect to a DB2 from Access using VBA code.
I have the connection string which I had used from online, but I am not able to connect to DB2. Is there anything else in the code that I'm missing which I should be putting in?
Because the Access file will be distributed to users, we can not go to the ODBC settings and hard code the username and password there, which is why we have to connect using the user's user id and password.
Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I can't see anywhere where you have defined the connection to the database.
http://www.connectionstrin
This has helped me with connection strings in the past:
1. In Notepad, or any other text editor, create a file named Temp.udl
2. Leave the file empty and save it to the Desktop
3. Double-click the Temp.udl file
4. The Data Link Properties dialog box appears
5. In the Data Link Properties dialog box, click Provider. Select the appropriate provider from the list
6. Click Connection and select the corresponding name of the server and the database
Type the User Name and the Password
7. Click Test Connection to test the connection
8. Click OK
9. Right-click Temp.udl and click 'Open With'
If Notepad shows up as an option, click it, otherwise click 'Choose Program' and navigate
through the list to notepad and select it
10. Copy the connection string to your application
> Provider=MSDASQL.1
I wouldn't expect that this is the correct provider if a DB2 database will be the target. I'd expect an IBM driver rather than a Microsoft one.
For me, the provider would show as [Provider=IBMDASQL.DataSou
However, I don't see anywhere in the thread that says where the target DB2 is installed. What DB2 are you going after? (And is anybody aware of a Microsoft driver actually working for the DB2 that is indicated?)
Tom
I'm able to make a connection, but I'm still not able to run the query...
After debugging, what I noticed was that it asks for my user ID and password at the pass thru query.
If I embed my userID and password in the pass thru query, then it runs through ok.
The current ODBC Connection String in the Passthru query is attached:
How can I embed the userid and password within the passthru query so I can run it?
If I'm asking a different question, please let me know and I'll gladly open another question.
Thanks.
This connection string is built automatically in Access.
1. Create a passthru query.
2. Right click and enter design view of the query.
3. Right click and enter Proprty.
4. Have the cursor be in ODBC Connect String textbox.
5. Click on "..."
6. ODBC Data Source is opened prompting you to enter the connection.
7. After selecting your data source, you click ok and your connection string is built for you for the passthru query by Access.
I think I got it from a previous question. Thanks for your help everyone!!
http://www.experts-exchang
Business Accounts
Answer for Membership
by: momi_sabagPosted on 2008-12-16 at 06:45:48ID: 23183967
which error do you receive?
are you sure you have db2 odbc drivers installed?