DSN checks fine, but login failed trying to use DSN for SQL Server 2005

I am writing a small ASP.NET application in a hosted environment (this means that I do not own the server).

Using the webtools of the hosting provider, I created a DSN that defines the driver, server, UID, PWD, and database. When I test the connection, it tests fine.

However, when I load my webpage with code:

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

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

I know that I am using the correct DSN name because when I go to "DSN = NonExistentDSN" I get another error.

I don’t understand why the login works when I test it, but not when I use it in the code. Since I don’t own the server, some of the usual troubleshooting tools are not available to me, but I will be grateful for any feedback the community has.

+4
source share
1 answer

DSN may not save the password. Did you try to provide login credentials?

OdbcConnection DB = new OdbcConnection("DSN=MyDSNName;UID=login;PWD=password;"); DB.Open(); 
+4
source

All Articles