以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请问这个代码怎么写?SQL  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=130427)

--  作者:hongye
--  发布时间:2019/1/21 21:49:00
--  请问这个代码怎么写?SQL
\'\'\'
Dim s As String = FileSys.ReadAllText(e.ProjectPath & "Attachments\\SqlServers.txt")
Dim arr() As String = s.Replace(vbcr,"").Split(vblf)
For i As Integer = 0 To 1
    Dim ipdata As 这里请问怎么写?
    ipdata.host = arr(i*3+2).Split("=")(1)
    If e.Name = "彬阳数据" Then
        If Filesys.FileExists(e.ProjectPath & "Attachments\\SqlServers.sipcg") Then
            For iy As Integer = 1 To 1
                Dim ip As String = ipdata.host
                e.ConnectionString = e.ConnectionString.Replace("192.168.0.17",ip)
            Next
            Exit For
        End If
    End If
Next

以下是SqlServers.txt的内容
Password=112233
User ID=user
Data Source=192.168.0.18
Password=112233
User ID=user
Data Source=bnang.oicp.net

我的想法是制作一个SqlServers.txt文件
如果内网IP:192.168.0.17没有反应时,自动转到内网192.168.0.18,如果还没反应的话转到公网的bnang.oicp.net的地址
写到这里感觉不知道怎么写了,请帮忙改一下

--  作者:有点蓝
--  发布时间:2019/1/21 22:16:00
--  
If e.Name = "彬阳数据" Then
    Dim cn As String = "Provider=SQLOLEDB.1;Password={0};Persist Security Info=True;User ID={1};Initial Catalog=Test;Data Source={2}"
    Dim s As String = FileSys.ReadAllText(e.ProjectPath & "Attachments\\SqlServers.txt")
    Dim arr() As String = s.Replace(vbcr,"").Split(vblf)
    For i As Integer = 0 To 1
        Dim ip As String = arr(i*3+2).Split("=")(1)
        If Network.Ping(ip,1000) Then
             e.ConnectionString = CExp(cn,arr(i*3).Split("=")(1),arr(i*3+1).Split("=")(1),arr(i*3+2).Split("=")(1))
            Exit For
        End If
    Next
End If