本文介绍了在应用程序运行中间的SQL Server登录失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有突然开始抛出以下异常的应用程序:I have an application that suddenly started throwing the following exception: System.Data.SqlClient.SqlException:用户登录失败用户名。用户名和密码是否正确和应用程序做一些查询/使用相同的登录插入引发异常之前。The username and password are correct and the app does some queries/inserts using the same login before throwing the exception.还有其他的原因,一个登录就可以开始失败?难道SQL Server的有可能已达到连接的默认最大数量?我使用LINQ to SQL的 - 不说我重用一个DataContext事实插入多行数据,而不是建立一个新的,每次有任何相关的后果What are some other reasons a login can start failing? Does SQL Server have a default maximum number of connections that may have been reached? I'm using LINQ to SQL - does the fact that I'm reusing a DataContext to insert multiple rows of data rather than creating a new one each time have any relevant consequences?推荐答案我认为这个问题与我的方式是创造DataContexts - 我在班里保持约一,创造一种新的方法,地域的一方每次我做了一个更新(见时间此处了解详细信息)。我只是重构代码创建一个新的DataContext每个事务和错误走了。I think the issue was with the way I was creating DataContexts - I was keeping one around in the class and creating a new method-local one every time I did an update (see here for more details). I just refactored the code to create a new DataContext for each transaction and the error went away. 这篇关于在应用程序运行中间的SQL Server登录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-23 07:50