Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DSN tests ok, but login failure trying to use the DSN to SQL Server 2005

Tags:

I'm writing a small ASP.NET application in a hosted environment (meaning I don't own the server).

Using the hosting provider's webtools, I created a DSN that specifies the Driver, the Server, the UID, the PWD, and the Database. When I test the connection, it tests out fine.

However, when I load my web page with the code:

OdbcConnection DB = new OdbcConnection("DSN=MyDSNName");
DB.Open();

I get the error: ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user ''.

I know I'm using the correct DSN name because when I change to "DSN=NonExistentDSN" I get a different error.

I don't understand why the logon works when I test it but not when I use it in code. Since I don't own the server, some of the usual troubleshooting tools aren't available to me, but I'd appreciate any feedback the community has.

like image 555
The Demigeek Avatar asked Aug 30 '09 23:08

The Demigeek


1 Answers

Perhaps the DSN does not retain the password. Have you tried to supply login credentials?

OdbcConnection DB = new OdbcConnection("DSN=MyDSNName;UID=login;PWD=password;");
DB.Open();
like image 165
Yannick Motton Avatar answered Oct 20 '22 18:10

Yannick Motton