如何修复System.Data.SqlClient.SqlException:用户

时间:2018-05-20 01:13:25

标签: c# connection-string sql-server-2017

当我运行它时,我得到了这个:

Error Screenshot

我在IIS,SQL Server中启用了Windows身份验证,并在web.config中添加了身份验证方法:

<system.web>
  <authentication mode="Windows"/>
<system.web>

我完全没有想法......

如您所见,DataConnection正在运行

DataConnection Screenshot

来自web.config的连接字符串:

<connectionStrings>
    <clear/>
    <add name="cafeaconnection" 
         connectionString="Data source=LENOVO-PC\SQLEXPRESS; Initial catalog=tipuridecafeaDB; user id=user; password=password; persist security info=True;" 
         providerName="System.Data.SqlClient" />
    <add name="ConnectionString" 
         connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\tipuridecafeaDB.mdf;Integrated Security=True" 
         providerName="System.Data.SqlClient"/>
</connectionStrings>

错误:

  

[SqlException(0x80131904):用户'Shade'登录失败。]

     

System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity身份,SqlConnectionString connectionOptions,SqlCredential凭证,对象providerInfo,字符串NEWPASSWORD,SecureString的newSecurePassword,布尔redirectedUserInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData,池类DBConnectionPool,字符串的accessToken,布尔applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)+907
  System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,DbConnectionPool池,DbConnection owningConnection,DbConnectionOptions userOptions)+334
  System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool池,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&amp; connection)+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 retry,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal&amp; connection)+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 retry,DbConnectionOptions userOptions)+21
  System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1 retry) +90
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1次重试)+443
  System.Data.SqlClient.SqlConnection.Open()+96
  D:\ YCS \ YourCoffeeShop \ YourCoffeeShop \ App_Code \ ConnectionClass.cs中的YourCoffeeShop.App_Code.ConnectionClass.GetCafeaByType(String cafeaType):29
  YourCoffeeShop.Pages.Cafea.FillPage()在D:\ YCS \ YourCoffeeShop \ YourCoffeeShop \ Pages \ Cafea.aspx.cs:26
  YourCoffeeShop.Pages.Cafea.Page_Load(对象发件人,EventArgs e)在D:\ YCS \ YourCoffeeShop \ YourCoffeeShop \ Pages \ Cafea.aspx.cs:17
  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

1 个答案:

答案 0 :(得分:0)

签入服务 某些 mssql 服务器服务可能已停止。我也遇到了同样的问题,现在启动后解决了。