Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not promted to login..? 1

Status
Not open for further replies.

Kujen

Technical User
Oct 13, 2007
57
SE
Hi all,

I have linked tables in Access to a SQL-server with SQL authentication.

For some reason I'm not promted to login after I run this code:
==========================
gStrConnect = "ODBC;DRIVER={SQL SERVER};SERVER=MyServer;Database=MyDb;UID=" & Me.strUserId & ";PWD=" & Me.strPassword

For Each Tdf In db.TableDefs
If InStr(1, Tdf.Connect, "MyDb") > 0 Then
With Tdf
.Connect = gStrConnect
.RefreshLink
End With
End If
Next
====================
If I delete all linked tables and link them again then I'm promted to login again. It seems to me that the connect string is stored somewhere.

What do I have to do so that I'm always promed to login?

Kent J.

 
gStrConnect = "ODBC;DRIVER={SQL SERVER};SERVER=MyServer;Database=MyDb;UID=" & Inputbox("what is the username?") & ";PWD=" & Inputbox("what is the password?")

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Hi,

Username and password is stored in the connectstring.
I don't think that's the problem.

If use a connect string that points to a DNS:
gStrConnect = "DSN=MyDNS;...."
then I'm promted to login

So when I use a connect string:
gStrConnect = "ODBC;DRIVER={SQL SERVER}..."
then I'm not promted to login.

The two string behaves differently.
Why?

Kent J.
 
When you create the DSN you can store the user and password in there as well.

When going through the wizard to create a new DSN right after you select the server name the next set of option has a choice for SQL Server Authentication. Did you set up the DSN yourself?

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Hi,

Yes, I set up the DSN myself.

But is the userid and password stored in Access somewhere when I use?: gStrConnect = "ODBC;DRIVER={SQL SERVER}..."

Kent J.

 
Ok. It looks like you want to be prompted. If so, then do not pass the password and userID in the connection string (i.e. ;UID=" & Me.strUserId & ";PWD=" & Me.strPassword).

I am assuming that your DSN does not have a password and userid stored and that is why it prompts you when you manually link the tables. The code above to refresh the links is passing the user and pwd from t he text boxes on the form and that is why it is not asking for it.



ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top