'ASP.NET Exception Error From SQL Server Windows Authentication Login
I have read and tried all the suggestions from [https://stackoverflow.com/questions/22415319/system-data-sqlclient-sqlexception-login-failed-for-user][3]
But none of those suggestions work. Thank you very much if you know why my setup have this error.
From SQL Server Studio Management, I am able to login with no error to SQL Server either locally through Windows Authentication or through a user account from another computer on the network. Both of my SQL server and IIS web server are residing on the same machine.
System Setups:
Server Operating System: Windows 7
SQL Server: SQL Server Developer version 2012: Run under Window's Administrator account
Web Server: IIS 7.5: Run under Window's Administrator account
SQL Server Authentication Mode: SQL Server and Windows Authentication Mode
IIS Server Application Pool Setting:
-Managed Pipeline Mode: Integrated Process
-Model Identity: Network Services
web.config Setting:
Connection string and system.web:
<add name="DBCS" connectionString="server=localhost;database=WebServer;integrated security=SSPI;persist security info=True"/>
<authentication mode="Windows"/>
Here is how I make connection to the SQL Server:
string connectionString = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection Conn = new SqlConnection(connectionString))
{
SqlCommand Cmd = new SqlCommand(queryString, Conn);
Cmd.Connection.Open();
Conn.Open();
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
Conn.Close();
}
Here is the error I got from the Chrome web browser:
Source Error:
Line 92: {
Line 93: SqlCommand Cmd = new SqlCommand(queryString, Conn);
Line 94: Cmd.Connection.Open(); <---- ERROR
Line 95: Conn.Open();
Line 96: Cmd.ExecuteNonQuery();
Stack Trace:
[SqlException (0x80131904): Login failed for user 'HJHHOME\HENRYJHU-PC$'.]
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +345
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +156
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +258
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +312
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +202
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +413
System.Data.SqlClient.SqlConnection.Open() +128
_Default.DBUpdate(String queryString) in c:\inetpub\henrywebroot\Default.aspx.cs:94
_Default.Page_Load(Object sender, EventArgs e) in c:\inetpub\henrywebroot\Default.aspx.cs:49
System.Web.UI.Control.OnLoad(EventArgs e) +106
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785
My Application Pool Setting:
Screenshot
Version of .Net Framework running on IIS Server:
Screenshot
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|