以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]断网提示会提示多次  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=180065)

--  作者:crazyfengyu
--  发布时间:2022/9/26 15:12:00
--  [求助]断网提示会提示多次
请问断网后会一直弹出    运行错误提示(套接字操作尝试一个无法连接的主机) 有没有办法只弹出一次?
--  作者:有点蓝
--  发布时间:2022/9/26 15:33:00
--  
执行什么代码弹出的错误?
--  作者:crazyfengyu
--  发布时间:2022/9/26 15:47:00
--  
在系统菜单 中 SystemIdle 里面进行数据库连接监听了

Dim ErrMsg As String
Dim Conn As String

If FileSys.FileExists(ProjectPath & "Attachments\\config.json") Then
    Dim configJson As String = FileSys.ReadAllText(ProjectPath & "Attachments\\config.json",Encoding.Default)
    Dim cjo As JObject = JObject.Parse(configJson)
    If cjo("config")(0) IsNot Nothing Then
        If cjo("config")(0)("type") = "database" Then
            C & cjo("config")(0)("host").ToString & "," & cjo("config")(0)("port").ToString & "\\" & cjo("config")(0)("name").ToString
        End If
    End If
End If

If Connections.TryConnect(Conn,ErrMsg) = False Then
    connbtn.SmallImage = GetImage("soffline.png")
Else
    connbtn.SmallImage = GetImage("sonline.png")
End If
[此贴子已经被作者于2022/9/26 15:53:40编辑过]

--  作者:有点蓝
--  发布时间:2022/9/26 15:56:00
--  
Dim ErrMsg As String
Dim Conn As String
try
If FileSys.FileExists(ProjectPath & "Attachments\\config.json") Then
    Dim configJson As String = FileSys.ReadAllText(ProjectPath & "Attachments\\config.json",Encoding.Default)
    Dim cjo As JObject = JObject.Parse(configJson)
    If cjo("config")(0) IsNot Nothing Then
        If cjo("config")(0)("type") = "database" Then
            C & cjo("config")(0)("host").ToString & "," & cjo("config")(0)("port").ToString & "\\" & cjo("config")(0)("name").ToString
        End If
    End If
End If

If Connections.TryConnect(Conn,ErrMsg) = False Then
    connbtn.SmallImage = GetImage("soffline.png")
Else
    connbtn.SmallImage = GetImage("sonline.png")
End If
catch ex as exception
if vars("show") = false then
msgbox(ex.message)
vars("show") = true
endif
end try