views:

99

answers:

1

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.

+1  A: 

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();
Yannick M.
Huh. That worked. Interesting. I wonder why.Of course, it totally defeats the purpose... the whole reason I chose to go with a DSN is so that I wouldn't have to code UID and PWD in the page code. Oh well, at least it's working now.
The Demigeek