以下是引用有点甜在2019/5/15 9:53:00的发言:
你这种思路本身就不正确。改成:不是切换,而是增加数据源,用完以后,移除,即可。数据源名,不要用同一个。
我说的就是这个方式:
Public Function SwitchingDataSources(ByVal e As RequestEventArgs, ByVal fy As String) As Boolean
Dim bool As Boolean = False
If fy > "" Then
Dim cmd As New SQLCommand
cmd.C
Dim dt As DataTable
cmd.CommandText = "S ele ct * From 手机端IP Where 分院名称='" & fy & "' And 链接 is not null"
dt = cmd.ExecuteReader
If dt.DataRows.Count > 0 Then
If Connections.TryConnect(dt.DataRows(0)("链接")) = True Then
If Connections.Contains(fy) = True Then
Connections.Delete(fy)
End If
Connections.Add(fy, dt.DataRows(0)("链接"))
return True
End If
End If
End If
Return false
End Function
就是这个代码 我一个人测试 还偶尔发现有相同数据源 报错的信息
[此贴子已经被作者于2019/5/15 10:01:01编辑过]