Dim s As String = "xxx" '数据库连接字符串
If Connections.TryConnect(s) Then '如果数据源可连接
If Connections.Contains("数据源A") Then
Connections("数据源A").ConnectionString = s
Else ' 新增数据源
Connections.Add("数据源A",s)
End If
Mydata = "数据源A"
end if