用户登录失败' DESKTOP-SBFCRKL \ Shaharyar Parekh'

时间:2017-11-21 10:44:18

标签: c# asp.net sql-server

我想将我的asp.net网页连接到SQL Server 2014.我的连接字符串是:

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

当我运行项目时,我得到:

**指服务器错误在' / onlineshoes'应用

  

无法打开数据库" OnlineShop"登录请求。登录   失败。用户登录失败' DESKTOP-SBFCRKL \ Shaharyar Parekh'。

     

描述:执行期间发生了未处理的异常   当前的网络请求。请查看堆栈跟踪了解更多信息   有关错误的信息以及它在代码中的起源。

     

异常详细信息:System.Data.SqlClient.SqlException:无法打开   数据库" OnlineShop"登录请求。登录失败。登录   用户失败' DESKTOP-SBFCRKL \ Shaharyar Parekh'。

     

来源错误:

     

第781行:this.Adapter.SelectCommand =   this.CommandCollection [0]; 782行:
  DS_CAT.CATEMST_SELECTDataTable dataTable = new   DS_CAT.CATEMST_SELECTDataTable(); 783行:
  this.Adapter.Fill(dataTable中);第784行:返回dataTable;   785行:}

     

源文件:c:\ Users \ Shaharyar Parekh \ AppData \ Local \ Temp \ Temporary   ASP.NET Files \ onlineshoes \ 11df693e \ 771d1f70 \ App_Code.rcz9orfq.2.cs
  行:783

     

堆栈追踪:

     

[SqlException(0x80131904):无法打开数据库" OnlineShop"   登录请求。登录失败。用户登录失败   ' DESKTOP-SBFCRKL \ Shaharyar Parekh'。]   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity   identity,SqlConnectionString connectionOptions,SqlCredential   凭证,Object providerInfo,String newPassword,SecureString   newSecurePassword,Boolean redirectedUserInstance,SqlConnectionString   userConnectionOptions,SessionData reconnectSessionData,   DbConnectionPool池,String accessToken,Boolean   applyTransientFaultHandling)+821
  System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions   options,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,   DbConnectionPool池,DbConnection owningConnection,   DbConnectionOptions userOptions)+332
  System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(类DBConnectionPool   pool,DbConnection owningObject,DbConnectionOptions选项,   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&连接)+426
  System.Data.ProviderBase.DbConnectionPool.TryGetConnection(的DbConnection   owningObject,TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
1重试,DbConnectionOptions   userOptions,DbConnectionInternal oldConnection,DbConnectionInternal&   连接)+191
  System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(的DbConnection   outerConnection,DbConnectionFactory connectionFactory,   TaskCompletionSource 1 retry, DbConnectionOptions userOptions) +154
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1重试,DbConnectionOptions userOptions)+21
  System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1 retry) +90
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1   重试)+209 System.Data.SqlClient.SqlConnection.Open()+96
  System.Data.Common.DbDataAdapter.FillInternal(DataSet数据集,   DataTable [] datatables,Int32 startRecord,Int32 maxRecords,String   srcTable,IDbCommand命令,CommandBehavior行为)+120
  System.Data.Common.DbDataAdapter.Fill(DataTable [] dataTables,Int32   startRecord,Int32 maxRecords,IDbCommand命令,CommandBehavior   行为)+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   文件\ onlineshoes \ 11df693e \ 771d1f70 \ App_Code.rcz9orfq.2.cs:783
  KPATEL_Home.Page_Load(Object sender,EventArgs e)in   F:\下载\压缩\ 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(布尔   includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)   678 **

有人知道如何解决这个问题吗?

3 个答案:

答案 0 :(得分:0)

尝试以下连接字符串:

connectionString="Data Source=.\SQLEXPRESS; 
Initial Catalog=OnlineShop; 
Integrated Security=True;"

答案 1 :(得分:0)

尝试此连接字符串

  <connectionStrings>
<add name="DefaultConnection" connectionString="Server=your-server-name; database=databaseName;Integrated Security=True" providerName="System.Data.SqlClient"/>
 </connectionStrings>

答案 2 :(得分:0)

我确实通过启动SQL Server(MSSQLSERVER)服务来解决此问题。 您可以按照以下步骤进行操作:

  1. 打开服务窗口(开始->所有程序-> Windows 管理工具->服务快捷方式)。
  2. 右键单击SQL Server(MSSQLSERVER)。
  3. 按开始。