Good day everyone! I've been having a problem, and I figure it out that I'm not the only one with this 'kind' of SQL Exception. But, I done everything that I found and with the same result. So, please, let me introduce my problem.
I've been working in asp.net web application. Developed in Visual Studio 2015 (community version). In my project I have some SQL Connection to my local database (in the same computer that my project). Everything is going well when I click "Debug" (with my favorite browser). I can make querys (select, inset, update, etc). Now I want to make it public in my intranet (my cowerkers want to wwork with this app as well). So, I moved my project folder to
C:\inetpub\wwwroot
And yes, the IIS web site is configured (correctly, I think, well I have another intranet apps working fine!)
The Default page in my web page is a Login.aspx and when I try to access with the correct keys (username and password), SQL shows me an error.
Invalid login attempt. Database issue.System.Data.SqlClient.SqlException (0x80131904): Error de inicio de sesión del usuario 'IIS APPPOOL\SADI'. en System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) en System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) en System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) en System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) en System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) en System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) en System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) en System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) en System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) en System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) en System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) en System.Data.SqlClient.SqlConnection.Open() en SADMIN.Login.btnLog_Click(Object sender, EventArgs e) en C:\Users\MyUser\Documents\Visual Studio 2015\Projects\MyProject\MyProject\Login.aspx.cs:line 43 ClientConnectionId:6cc4ef30-4720-4c45-ba87-d85f39804685 Error Number:18456,State:1,Class:14 Enviar
And if your're wondering... This is my line 43:
conn.Open();
And this my BackCode in the Login.aspx
try
{
SqlConnection conn = new SqlConnection(@"Integrated Security=SSPI;Persist Security
Info=False;User ID=sa;Initial Catalog=MyDatabase;Data
Source=PCUsername\SQLInstance");
SqlCommand cmd = new SqlCommand();
SqlDataReader reader;
cmd.CommandText = "spcLoginValidate";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = txtusername.Text;
cmd.Parameters.Add("@passw", SqlDbType.VarChar).Value = txtpassword.Text;
cmd.Connection = conn;
conn.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
idRole = Convert.ToInt32(reader[0].ToString());
Session["User"] = reader[1].ToString();
Session["ID"] = idRole;
}
reader.Close();
conn.Close();
lblError.Visible = true;
}
catch (Exception ex)
{
lblError.Text = "Invalid login attempt. Database issue." + ex;
lblError.Visible = true;
}
In the Catch section I have the labelError whith the SQL Exception, and in that label is where my web page shows me the error that I gave you before.
My SQL Server services are running, so I don´t know what to do! Any help from you guys it would be awesome! I've been trying to resolve this issue for 3 days, and still have it.