深圳全飞鸿

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 749|回复: 1
打印 上一主题 下一主题

网络不稳定导致的系统报错的改善方案

[复制链接]

800

主题

1379

帖子

7725

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7725
跳转到指定楼层
楼主
发表于 2019-5-13 20:06:08 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
XC的SMT系统工作在wifi模式下,由于网络的不稳定,偶尔会有以下报错



现针对该问题做出改善方案!
回复

使用道具 举报

800

主题

1379

帖子

7725

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7725
沙发
 楼主| 发表于 2019-5-13 22:51:21 | 只看该作者
  1. Public Function CheckDB()
  2. Dim res As Boolean
  3. Dim yn As Integer
  4. Dim count As Integer
  5. count = 0
  6. Do
  7.   count = count + 1
  8.   res = CheckDataBase("SYANT")
  9.   If res Then
  10.      yn = vbNo
  11.   Else
  12.     yn = MsgBox("MES数据库重连失败,是否继续尝试重连?" & CStr(count), vbYesNo, "MES")
  13.   End If
  14. Loop While (res = False) And (yn = vbYes)
  15. End Function

  16. Public Sub session_start()
  17.     Dim StrSql As String
  18.     Dim res As String
  19.     Dim adors1 As ADODB.Recordset
  20.     StrSql = "CALL syant.session_start('TR_IQC','1.1.8','',TRUE,@x);"
  21.     Set adors1 = CN.Execute(StrSql)
  22. End Sub

  23. Public Function CheckDataBase(app_name As String) As Boolean
  24. Dim StrSql As String
  25. Dim res As String
  26. Dim adors1 As ADODB.Recordset
  27. On Error GoTo chkError
  28. CheckDataBase = False
  29. StrSql = "select now() from dual "
  30. Set adors1 = CN.Execute(StrSql)
  31. ' so ok!
  32. adors1.Close
  33. Set adors1 = Nothing
  34. CheckDataBase = True
  35. Exit Function
  36. chkError:
  37.     On Error GoTo DataBaseError
  38.     res = NSD_APM.ReConnect(app_name)
  39.     If res = "ReConnect OK!" Then
  40.       Set CN = Nothing
  41.       Set CN = NSD_APM.CN
  42.       CheckDataBase = True
  43.       Call session_start
  44.     Else
  45.       'MsgBox Err.Description, vbCritical, "MES数据库重连失败!"
  46.     End If
  47.     Exit Function
  48. DataBaseError:
  49.     'MsgBox Err.Description, vbCritical, "MES数据库重连失败!"
  50. End Function
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|nagomes  

GMT+8, 2025-6-29 01:51 , Processed in 0.062810 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表