我试图运行链接到两台服务器的存储过程。存储过程完全从SSMS运行,但它不会从我的VB.Net代码运行。如果我删除对链接服务器的引用,它将正确运行。但是,我需要存储过程中的链接服务器引用。
正确设置了4部分参考。链接的服务器连接已正确设置。我们似乎认为它是VB中的数据连接,但我们已经尝试了所有内容,但我们不断收到登录映射错误。
连接字符串如下。我们基本上从存储IP地址和登录信息的XML文件中提取。那是" / Settins / Catalogs ......"变量
Public Shared Function GetConnString(ByVal sConn As String) As SqlClient.SqlConnectionStringBuilder
_dbServer = GetBakerGlobalSettingsValue("/Settings/Catalogs/SNL/DataSource")
_dbLoginName = GetBakerGlobalSettingsValue("/Settings/Catalogs/SNL/UserId")
_dbLoginPassword = GetBakerGlobalSettingsValue("/Settings/Catalogs/SNL/Password")
_InitialCatalog = "SNL"
Dim sbConnString As New SqlClient.SqlConnectionStringBuilder
sbConnString.DataSource = _dbServer
sbConnString.InitialCatalog = _InitialCatalog
sbConnString.UserID = _dbLoginName
sbConnString.Password = _dbLoginPassword
sbConnString.IntegratedSecurity = False
Return (sbConnString)
End Function
Dim aDate As Date = "2010-06-30"
Using sqlCommand As New SqlCommand("VerifyPortfolioFedIds '" & aDate & "'", connPort)
sqlCommand.CommandTimeout = 300
Dim da As SqlDataAdapter = New SqlDataAdapter() With {.SelectCommand = sqlCommand}
Dim dt As DataTable = New DataTable
da.Fill(dt)
MsgBox(dt.Rows.Count.ToString)
End Using