当我编码时,下面的代码工作正常。我在 IIS 中发布代码,然后连接失败。
我知道,当我编码时将我的窗口登录作为凭据,而在 IIS 中它正在使用 AppPool Identity。如何将我的 Windows 登录凭据传递给连接字符串?
Public Shared Function DbCollection(connectionString As String) As DatabaseCollection
Dim server As New Microsoft.SqlServer.Management.Smo.Server(connectionString)
Return server.Databases
End Function
错误:
Login failed for user 'Domain\Computername$'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user
'Domain\Computername$'.