Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
计时器使用while语句触发mysql-不获取所有数据_Mysql_Vb.net - Fatal编程技术网

计时器使用while语句触发mysql-不获取所有数据

计时器使用while语句触发mysql-不获取所有数据,mysql,vb.net,Mysql,Vb.net,我开发了一个winform,它需要经常与mysql数据库联系,以确保所有的“调用”都被获取并且是最新的——我遇到的问题是,我的listview每次定时器点击只填充一行。此计时器应激活一个while语句,该语句应处理所有数据,并且实际上还应清除listview以接收更新的数据。为什么我的listview每个刻度只填充1个项目 Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick L

我开发了一个winform,它需要经常与mysql数据库联系,以确保所有的“调用”都被获取并且是最新的——我遇到的问题是,我的listview每次定时器点击只填充一行。此计时器应激活一个while语句,该语句应处理所有数据,并且实际上还应清除listview以接收更新的数据。为什么我的listview每个刻度只填充1个项目

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    ListView2.Items.Clear()
    con.ConnectionString = "server=localhost;" _
& "user id=username;" _
& "password=password;" _
& "database=DMT"
        adptr = New MySqlDataAdapter("SELECT * , s.fid AS sfid, s.name AS sname, s.faddress AS sfaddress, s.fcity AS sfcity, s.fstate AS sfstate, s.fcontnumb AS sfcontnumb, s.fcontname AS sfcontname, s.fcontract AS sfcontract, d.fid AS dfid, d.name AS dname, d.faddress AS dfaddress, d.fcity AS dfcity, d.fstate AS dfstate, d.fcontnumb AS dfcontnumb, d.fcontname AS dfcontname, d.fcontract AS dfcontract FROM calls c LEFT JOIN facilities s ON c.Scene = s.fid LEFT JOIN facilities d ON c.Dest = d.fid WHERE putime < now( ) + INTERVAL 12 HOUR && Rdisp IS NULL ORDER BY putime desc", con)
    Try
        adptr.Fill(pendrun)
    Catch err As Exception
        Dim strError As String = "Exception: & err.ToString()"
    End Try
    If pendrun.Rows.Count > 0 Then
        While pop < pendrun.Rows.Count - 1
            TempStr(0) = pendrun.Rows(pop)("RID")
            Select Case pendrun.Rows(pop)("Utype")
                Case 1
                    TempStr(1) = "BLS Ambulance"
                Case 2
                    TempStr(1) = "ALS Ambulance"
                Case 3
                    TempStr(1) = "SCT Ambulance"
                Case 4
                    TempStr(1) = "Wheelchair Van"
                Case 5
                    TempStr(1) = "Taxi"
            End Select

            Select Case pendrun.Rows(pop)("Curgency")
                Case 1
                    TempStr(2) = "Scheduled"
                Case 2
                    TempStr(2) = "Non-Scheduled"
                Case 3
                    TempStr(2) = "ASAP"
                Case 4
                    TempStr(2) = "STAT"
            End Select
            TempStr(3) = pendrun.Rows(pop)("Pname")
            TempStr(4) = pendrun.Rows(pop)("Texttime")
            TempStr(5) = pendrun.Rows(pop)("sname") & " - " & pendrun.Rows(pop)("sfaddress") & ", " & pendrun.Rows(pop)("sfcity") & ", " & pendrun.Rows(pop)("sfstate")
            TempStr(6) = pendrun.Rows(pop)("dname") & " - " & pendrun.Rows(pop)("dfaddress") & ", " & pendrun.Rows(pop)("dfcity") & ", " & pendrun.Rows(pop)("dfstate")
            TempNode = New ListViewItem(TempStr)
            ListView2.Items.Add(TempNode)
            pop += 1
        End While
    End If

End Sub
Private Sub Timer1\u Tick(发送方作为对象,e作为事件args)处理Timer1。Tick
ListView2.Items.Clear()
con.ConnectionString=“服务器=本地主机;”_
&“用户id=用户名;”_
&“密码=密码;”_
&“数据库=DMT”
adptr=新的MySqlDataAdapter("选择*,s.fid作为sfid,s.name作为sname,s.faddress作为sfaddress,s.fcity作为sfcity,s.fstate作为sfstate,s.fcontnumb作为SFontnumb,s.fcontname作为sfcontname,s.fcontract作为sfcontract,d.fid作为dfid,d.name作为dname,d.faddress作为dfaddress,d.fcity作为dfcity,d.fstate作为dfcontnumb,d.fcontnumb作为dfcontnumb,d.fcontname作为dfcontname,d.FContact作为dfcontract从调用c上的c左连接设施s开始。场景=s.fid左连接设施d在c上。目的地=d.fid,其中putime0,则
而pop
通过将计时器从1秒更改为30秒,我已经验证了它实际上是直接链接到计时器的(每勾1个项目),并且它确实直接改变了这一点。

您的代码永远不会重置“pop”“……的价值。我敢肯定,这就是造成麻烦的原因。它保持每刻度增加1个值,但无法完成所有操作,因为pop设置为比while的最大值小一个