何时指定providerName=“System.Data.SqlClient”在连接字符串中
我在 NT AUTHORITY\LOCAL SYSTEM
下运行的 Windows 服务出现问题,导致该服务无法连接到数据库。
Login failed for user 'NT AUTHORITY\LOCAL SERVICE'. Reason: Failed to open the explicitly specified database.
为此特定服务指定的连接字符串与同一帐户下运行的另一个服务之间的唯一区别是缺少 providerName
属性。一旦我添加
providerName="System.Data.SqlClient"
到连接字符串,服务就可以访问数据库。谁能解释为什么会这样?我认为 System.Data.SqlClient 是默认提供程序。
I had an issue with a Windows service running under NT AUTHORITY\LOCAL SYSTEM
whereby the service could not connect to a database.
Login failed for user 'NT AUTHORITY\LOCAL SERVICE'. Reason: Failed to open the explicitly specified database.
The only difference between the connection string specified for this particular service and another service running under the same account was that the providerName
attribute was missing. Once I added
providerName="System.Data.SqlClient"
to the connection string the service could access the database. Can anyone explain why this would be? I thought System.Data.SqlClient was the default provider.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您想要使用 SQLClient 提供程序来管理连接时。
SQLClient 提供程序管理与 Microsoft SQL Server 的连接。
这里是代码示例
不过,您永远不必指定它,因为它也是提供商的默认值。
When you want to use the SQLClient provider to manager the connection.
SQLClient provider manages connections to Microsoft SQL Servers.
Here is a code example
You never have to specify it though, as its also the default value for the provider.