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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB Connection failing when connection string has password

Status
Not open for further replies.

bsal81

Programmer
Jul 26, 2007
8
US
OK, I'm really at a loss on this one.

I have a small VB6 App that connects to a SQL 2005 Express database using a connection string that gets built in code. For some reason it is failing with a "login failed for user" error when running on Vista only and the user I'm trying to login as has a password associated with it. I'm certain that the password is getting added to the connection string correctly, 1. because it works on XP, 2. because I wrote the connection string to a file before it attempts to connect, and 3. because I can connect through osql using that same user and password. I've thought UAC may be causing it but I turned that off and it still fails. I've thought that running the app in compatibility mode for XP SP2 but that didn't work either. Any Ideas here are welcome. I'm stumped.

Below are the connection strings I've tried. The first one without the password works fine but the second one with the password does not.

"Provider=SQLOLEDB;Data Source=(local);User ID=TestUser;Initial Catalog=TestDatabase;"

"Provider=SQLOLEDB;Data Source=(local);User ID=TestUser;Password=test;Initial Catalog=TestDatabase;
 
One way to prove this is to within windows create an File ODBC connection - (remembering where this is stored).
Make sure the test connection works well, once proven open the ODBC connection and check the parameters

The other thing is to ensure you can connect (via query analyser) to the DB you require using the same login and password.

BTW : The connection string looks fine to me

"I'm living so far beyond my income that we may almost be said to be living apart
 
Thanks for the help. I'm afraid I'm not farmiliar with how to create an File ODBC Connection though. Can you provide some instruction on how to do this? I don't have any sort of SQL Express management studio installed on this machine.
 
click start, program files, administrative tools, Data Sources. Create file DSN.


"I'm living so far beyond my income that we may almost be said to be living apart
 
Alright, I did that. Created the DSN and at the end I tested the connection using the same UID and password that I was using in the connection string and it says tests completed successfully. Don't know where this puts me. I guess there would have to be something wrong with the connection string? It sure looks ok to me though.

 
what you can do now is locate this file DSN, put it all in a single line seperated by semi-colons and then use this as your connection string.

This means its the same settings exactly.

After that, and without access to your machine, I am stumped.

"I'm living so far beyond my income that we may almost be said to be living apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top