Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2005, 12:34 PM
YP YP is offline
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Posting ADO DSN-string to "Queries to server"

Hi,

Please help to decide the problem:
I am programming Access interface to MySQL-Database through ODBC. I need use both "Queries to server" and some special queries, made via ADO.
All "Queries to server" have default DSN-string which has all ODBC-DSN-data but not contain user-specific info such as UID and PWD (this is multy-user application).
When I call any of this "Queries to server" ODBC authentification window is pop up. After right Login and Password input other connected objects ("Queries to server", "Connected tables") with the same DSN does not require login and password input and use the same connection. Similar picture is when I connect using DAO.- All connected objects use DAO connection string.
 But in ADO case "Queries to server" use own default DSN string and ignore ADO ConnectionString string. As result, "Queries to server" produces ODBC-connection error, becouse they does not contain UID and PWD into default DSN string.

My question is:

 How to force "Queries to server" to use ADO Connection string instead own default DSN-string.

 Forward thank you to any help.:)

 
Old June 30th, 2005, 04:38 AM
YP YP is offline
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Remarks: "Queries to server" is English-Russian-English translation of "Pass-through Queries", "Connected tables" => "Linked tables"

Impossible, SourceConnectStr property is decision but I have a question:
What object property SourceConnectStr of?

 
Old July 1st, 2005, 07:05 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   Let me try to answer some of your questions:

1. To use the DSN connection, you have to state it in your connection and recordset instantiation, like this:

'----------
Set cnn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cnn.Open "DSN=YourDSNName;"
'----------

2. To pass the UID and password, you need to add them to this line:

'----------
Set cnn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cnn.Open "DSN=YourDSNName;", strUID, strPassword
'----------

Now, where you gather the username and password is up to you. I have a script that I use this on, and I just add the values in plain text:

'----------
Dim strUID As String
Dim strPassword As String

strUID = "My User ID"
strPassword = "Password"

'----------

I am not sure how you can get this info, other than prompting the user, or putting it into the plain text of the code.

If you can get your user's uid (like their computer login name) and then prompt them for their password when they open the database, that wouldn't be so bad.

If the UID and password for the MySQL server are different than the user's credentials (since you didn't set up an account for each user on the server, but are using a generic login for each user [bad practice]) then I would do the following:

Place some hidden data field on the main form that opens when the user opens that database. This will prompt the user for the userid and password for the MySQL account. It will also look like database security. Anyway, they will only be prompted for the UID and password when they first open the database, which is not unusual. I have done this.

You may want to go to your DSN registry entry and change the last logged in user to the generic userID they need to log into the server. This will make sure that when each user logs in, they will only see the generic UID, and not some administrator's UID. You can do this in the code for the On Open event of the main form, like this...

'----------
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite "HKLM\Software\ODBC\ODBC.INI\YourDSNName\LastUser" , "GenericUID"
'----------

If you are using Access 2003 in sandbox mode, this may not work.


HTH



mmcdonal
 
Old July 2nd, 2005, 04:19 AM
YP YP is offline
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank You for answer!

This night I found that looking for.
Some later I'll publish my result.
In Russian it is on the http://www.it-ru.de/forum/viewtopic.php?p=923198#923198







Similar Threads
Thread Thread Starter Forum Replies Last Post
how to config db connection in a DSN-less server congfuzi Dreamweaver (all versions) 4 June 27th, 2008 06:45 PM
Connect SQL Server 2k with VB from DSN and DBQ ayan.mukherjee SQL Language 0 February 12th, 2008 02:26 AM
posting form data as XML string problem Cragdo XML 0 July 16th, 2007 10:03 AM
about changing dsn & server.mappath liniyer_667 Classic ASP Databases 0 June 12th, 2005 11:18 AM
DAO to ADO conversion ( saved queries,filters,etc tcarnahan Access 6 January 26th, 2004 10:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.