• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:


Hi Experts ..

Login failed for user 'CO-B080FE8CE82C\ASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'CO-B080FE8CE82C\ASPNET'.

Source Error:

Line 36:                   if(!IsPostBack)
Line 37:                   {
Line 38:                         sqlDataAdapter1.Fill(dsPizzaStores1);
Line 39:                         sqlDataAdapter2.Fill(dsPizzaStores1);
Line 40:             
I don't know why this error occured??
this is my connection string :

this.sqlConnection1.ConnectionString = "workstation id=\"CO-B080FE8CE82C\";packet size=4096;integrated security=SSPI;data source=\"CO-B080FE8CE82C\";persist security info=False;initial catalog=PizzaStore";

  • 3
  • 3
1 Solution
You need to give the ASPNET user access to the database or impersonate a user that already has database access. You can impersonate another user by adding this line to the web.config:

<identity impersonate="true" userName="CO-B080FE8CE82C\database_user" password="dbpassword"/>

Also, giving the ASPNET user access to resources (such as a database) can be a security risk, so I would recommend impersonating another user.

A second option would be to use SQL User Authentication instead of an SSPI context.


DrAskeAuthor Commented:
Actually ... I'm not familiar in web.config ?? I'm studing ADO.NET and I am developing a sample project (Asp.net web application project instead of using windows-Forms) ..

so how to set SQL User Authentication ??
To use SQL User Authentication, your sql server must be setup to support it. If it is, simply change your connection string to something like:

"server=CO-B080FE8CE82C;user id=sqluser;password=mypassword;initial catalog=PizzaStore;"

Where sqluser and mypassword are the user credentials for your sql user.

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

DrAskeAuthor Commented:
I added a new user using Enterprize Manager .. User = pizza ; password= pwpizza
but it gives another error :

Login failed for user 'pizza'. Reason: Not associated with a trusted SQL Server connection.

this.sqlConnection1.ConnectionString = "data source=CO-B080FE8CE82C;initial catalog=PizzaStore;user id=pizza; Password=pwpizza";

sorry for this stupid question :(
Try this:

1) Open Enterprise Manager.
2) Right-click on the SQL server instance
3) Choose "Properties" from the context menu. The "SQL Server Properties (Configure)" window will open
4) Choose the "Security" tab and make sure that under the "Authentication" header that "SQL Server and Windows" is selected.

That will enable SQL Server authentication so that your connection string will work.


DrAskeAuthor Commented:
Well *whatsit2002* .. it worked ..
Thanx alot ..
and sorry for wasting your time ..

regards, Ahmad;

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now