Question
Sagun Tangsrisanguan · May 30, 2022

Fetch data from global to text file but show communication Error

Hi

I use VB.net and add reference VISM.OCX in my project to fetch my data in global ^ztonMS it had 4000 record 

code is

 AxVisM1.MServer = "CN_IPTCP:" & TCLServer & ":" & Authen
        AxVisM1.NameSpace = TCLNamespace

        AxVisM1.P0 = ""
        AxVisM1.P1 = ""
        AxVisM1.P2 = ""

        AxVisM1.P3 = ""

       AxVisM1.P4 = ""

        'AxVisM1.Execute("d RefRange^NHSNAV2")

        While True
            AxVisM1.Execute("set P0=$o(^ztonMS(""REF"",P0))")
            AxVisM1.Execute("s P1=$g(^ztonMS(""REF"",P0))")

            xP1 = AxVisM1.P0.ToString

            If (AxVisM1.P0.ToString = "") Then
                Exit While
            End If

            While True
                AxVisM1.Execute("set P3=$o(^ztonMS(""REF"",P0,P3))")
                AxVisM1.Execute("s P4=$g(^ztonMS(""REF"",P0,P3))")

                If (AxVisM1.P3.ToString = "") Then
                    Exit While
                End If

                TmpTxT = AxVisM1.P4.ToString

                TCCode = Split(TmpTxT, vbTab)(1)
                TCDesc = Split(TmpTxT, vbTab)(2)
                TCDesc = Replace(TCDesc, "'", "''")
                Active = Split(TmpTxT, vbTab)(3)
                Unit = Split(TmpTxT, vbTab)(4)
                ResultFormat = Split(TmpTxT, vbTab)(5)
                digit = Split(TmpTxT, vbTab)(6)
                age = Split(TmpTxT, vbTab)(7)
                gender = Split(TmpTxT, vbTab)(8)
                EffDateFrom = Split(TmpTxT, vbTab)(9)
                EffDateTo = Split(TmpTxT, vbTab)(10)
                LowRange = Split(TmpTxT, vbTab)(11)
                HighRange = Split(TmpTxT, vbTab)(12)
                console.write(TCCode & "-" &  TCDesc & "-" &   Active & "-" &   Unit & "-" &   ResultFormat & "-" &   digit & "-" &   age & "-" &   gender & "-" &   EffDateFrom& "-" &   EffDateTo & "-" &   LowRange & "-" &   HighRange)

after I run for a while it show communication error

I Check my network connection it ok not timeout , I check data in variable it not have a special charactor

 

Could you suggest how to fix or check what is a root cause of this error

Product version: HealthShare 2016.1
$ZV: Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2014.1.5 (Build 851_7_19092U)
0
0 89
Discussion (1)1
Log in or sign up to continue

your exit statement

If (AxVisM1.P0.ToString = "") Then
	Exit While
End If

is to late, this must come after the $ORDER() statement

AxVisM1.Execute("set P0=$o(^ztonMS(""REF"",P0))")
If (AxVisM1.P0.ToString = "") Then
	Exit While
End If
AxVisM1.Execute("s P1=$g(^ztonMS(""REF"",P0))")

The same goes for the next while-loop a few lines below