Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 用户登录失败';sa';。原因:未与受信任的SQL关联_.net_Sql Server_Exception Handling_Ado.net_Windows Services - Fatal编程技术网

.net 用户登录失败';sa';。原因:未与受信任的SQL关联

.net 用户登录失败';sa';。原因:未与受信任的SQL关联,.net,sql-server,exception-handling,ado.net,windows-services,.net,Sql Server,Exception Handling,Ado.net,Windows Services,我正在开发一个windows服务,将数据从一个远程数据库传输到另一个数据库 当我尝试连接到数据库时,出现以下错误。此连接字符串在web应用程序中工作正常 仅当我尝试使用windows服务连接数据库时,才会出现此错误 System.Data.SqlClient.SqlException: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection. at System.Data

我正在开发一个windows服务,将数据从一个远程数据库传输到另一个数据库

当我尝试连接到数据库时,出现以下错误。此连接字符串在web应用程序中工作正常

仅当我尝试使用windows服务连接数据库时,才会出现此错误

System.Data.SqlClient.SqlException: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at WindowsService.Program.timer1_Elapsed(Object sender, EventArgs e) in E:\Trigger\WindowsService\WindowsService\Program.cs:line 93
我正在使用的Connectionstring:

SqlConnection con = new SqlConnection("Data Source=TAG2;Initial Catalog=A10;User ID=sa; pwd=root;Integrated Security=False");"

sql server很可能设置为“仅限windows身份验证”模式


请参阅此以解决错误。

sql server很可能设置为“仅限windows身份验证”模式


请参阅此以解决错误。

尝试检查数据库上的设置-您可能需要从更改身份验证方法 “仅限Windows”到“SQL身份验证”


您可以阅读更多内容

尝试检查数据库上的设置-您可能需要从更改身份验证方法 “仅限Windows”到“SQL身份验证”


作为默认安装,您可以阅读更多内容,我认为,它设置为仅允许Windows身份验证。但是,使用SQLServerManagementStudio(如果使用),可以启用SQLServer身份验证。按照此处的链接进行安装作为默认安装,我认为它设置为只允许Windows身份验证。但是,使用SQLServerManagementStudio(如果使用),可以启用SQLServer身份验证。此处跟随链接

我进入了混合模式,但仍有相同的错误。我进入了混合模式,但仍有相同的错误。假设链接已断开。假设链接已断开。