Login failed for user 'DESKTOP-SBFCRKL\Shaharyar Parekh'

-1

I want to connect my asp.net web page to SQL Server 2014. My connection string is:

connectionString="Data Source=DESKTOP-SBFCRKL\SQLEXPRESS; 
    Initial Catalog=OnlineShop; 
    Integrated Security=True;"

When I run the project I get:

**> Server Error in '/onlineshoes' Application.

Cannot open database "OnlineShop" requested by the login. The login failed. Login failed for user 'DESKTOP-SBFCRKL\Shaharyar Parekh'.

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: Cannot open database "OnlineShop" requested by the login. The login failed. Login failed for user 'DESKTOP-SBFCRKL\Shaharyar Parekh'.

Source Error:

Line 781: this.Adapter.SelectCommand = this.CommandCollection[0]; Line 782:
DS_CAT.CATEMST_SELECTDataTable dataTable = new DS_CAT.CATEMST_SELECTDataTable(); Line 783:
this.Adapter.Fill(dataTable); Line 784: return dataTable; Line 785: }

Source File: c:\Users\Shaharyar Parekh\AppData\Local\Temp\Temporary ASP.NET Files\onlineshoes\11df693e\771d1f70\App_Code.rcz9orfq.2.cs
Line: 783

Stack Trace:

[SqlException (0x80131904): Cannot open database "OnlineShop" requested by the login. The login failed. Login failed for user 'DESKTOP-SBFCRKL\Shaharyar Parekh'.]
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) +821
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +332
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +699
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +89
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +426
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +191
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +154
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 retry, DbConnectionOptions userOptions) +21
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) +90
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1 retry) +209 System.Data.SqlClient.SqlConnection.Open() +96
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +120
System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +160 System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +108
DS_CATTableAdapters.CATEMST_SELECTTableAdapter.select() in c:\Users\Shaharyar Parekh\AppData\Local\Temp\Temporary ASP.NET Files\onlineshoes\11df693e\771d1f70\App_Code.rcz9orfq.2.cs:783
KPATEL_Home.Page_Load(Object sender, EventArgs e) in f:\Downloads\Compressed\onlineshoes\Home.aspx.cs:26
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678**

Does anybody know how to solve this issue?

c#
asp.net
sql-server
asked on Stack Overflow Nov 21, 2017 by Muhammad Shaharyar • edited Nov 21, 2017 by Muhammad Shaharyar

3 Answers

0

Try following connection string:

connectionString="Data Source=.\SQLEXPRESS; 
Initial Catalog=OnlineShop; 
Integrated Security=True;"
answered on Stack Overflow Nov 21, 2017 by Abhishek Maurya
0

Try this connection string

  <connectionStrings>
<add name="DefaultConnection" connectionString="Server=your-server-name; database=databaseName;Integrated Security=True" providerName="System.Data.SqlClient"/>
 </connectionStrings>
answered on Stack Overflow Nov 21, 2017 by eraufi
0

I did resolve this by Starting the SQL Server (MSSQLSERVER) service. You can do this as below:

  1. Open Services window (Start -> All Programs -> Windows Administrative Tools -> Services shortcut).
  2. Right Click on SQL Server (MSSQLSERVER).
  3. Press Start.

User contributions licensed under CC BY-SA 3.0