关于使用Visual studio链接Sql Server数据库一直提示登录失败的问题

查看 84|回复 9
作者:15198743250   
有没有大佬知道这个要怎么解决的?
关于使用Visual studio链接Sql Server数据库一直提示登录失败的问题
[i]
[i]
[i]
报错:
System.Data.SqlClient.SqlException
  HResult=0x80131904
  Message=用户 'sa' 登录失败。
  Source=.Net SqlClient Data Provider
  StackTrace:
   at 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, SqlAuthenticationProviderManager sqlAuthProviderManager)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at WindowsFormsApplication2.DataBase.Connection(SqlConnection conn) in D:\USER\RuningData\20230606\机试作业\国产热剧信息查询\WindowsFormsApplication2\WindowsFormsApplication2\class\DataBase.cs:line 27
   at WindowsFormsApplication2.DataBase.sqlQuery(String sql) in D:\USER\RuningData\20230606\机试作业\国产热剧信息查询\WindowsFormsApplication2\WindowsFormsApplication2\class\DataBase.cs:line 48
   at WindowsFormsApplication2.Form1..ctor() in D:\USER\RuningData\20230606\机试作业\国产热剧信息查询\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs:line 17
   at WindowsFormsApplication2.Program.Main() in D:\USER\RuningData\20230606\机试作业\国产热剧信息查询\WindowsFormsApplication2\WindowsFormsApplication2\Program.cs:line 19

信息查询, 提示

px307   


15198743250 发表于 2023-6-7 17:06
两个命令运行了都是显示这样的

命令都成功了,你回到昨晚的版本,再执行程序看看还是登录失败的错误吗
15198743250
OP
  

[i]
px307   

https://blog.csdn.net/yangzijiangtou/article/details/113866906
15198743250
OP
  


px307 发表于 2023-6-6 19:52
https://blog.csdn.net/yangzijiangtou/article/details/113866906

一直是混合模式的
hrh123   

首先应该检查VS和SQLServer本身的,问题,如果按楼主说的已经启用了SQLServer验证方式,那么应检查是否有有效的SSL证书,可以在VS和SQLServer的管理界面内调试.当然,根据报错信息,我认为最有可能是用户名或密码错了,或者是没有数据库的权限,建议楼主确认一下.如果问题还没解决,可以看一下微软的文档来定位具体错误https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/connect/network-related-or-instance-specific-error-occurred-while-establishing-connection
px307   


15198743250 发表于 2023-6-6 20:31
一直是混合模式的

你的问题是新出来的?以前是正常的吗?数据库重启了吗?
15198743250
OP
  


px307 发表于 2023-6-6 22:35
你的问题是新出来的?以前是正常的吗?数据库重启了吗?

重启了,账号密码我百分百肯定是对的
px307   


15198743250 发表于 2023-6-6 22:50
重启了,账号密码我百分百肯定是对的

是不是连接串不对呢有加 Integrated Security=False 吗
15198743250
OP
  


px307 发表于 2023-6-6 23:08
是不是连接串不对呢有加 Integrated Security=False 吗

写没写这个,都是一样报登录失败
您需要登录后才可以回帖 登录 | 立即注册

返回顶部