MSSQL login fails but Test Connection Succeeds

J

John Spiegel

Hi all,

I've been working through a simple example using the SQL Server Northwind
database installed on my development machine. The example uses the Data
Form Wizard and when I set up the connection there it tests fine. When I
try to run the page it gives "Login failed for user 'ASPNET'". I've tried
both NT-integrated security and added an "ASPNET" user to SQL Server.
Still same issue--test works, running doesn't. Any pointers where to look?

TIA,

John
 
K

Ken Cox [Microsoft MVP]

Something to test is to be sure you know who the user is at the time ASP.NET
is looking to make the connection.

You can determine this with code like:

Dim wi As System.Security.Principal.WindowsIdentity = _
WindowsIdentity.GetCurrent
lblAuthenticatedUser.Text = wi.Name
 
J

John Spiegel

Thanks, Ken!

It is indeed running under the ASPNET account. I managed to get it working
by changing the connection string that the wizard had produced. Although,
it was admittedly more of a copy and paste from something else that had
worked than my deep understanding of the options for connection strings.

Is there a setting (global.asax? machine.config?) where I could either set
the account it runs under or some related way of getting more control?

Thanks, again,

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top