Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.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/flutter/9.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
Vb.net 在读卡器关闭时调用NextResult的尝试无效。运动模拟_Vb.net_Datareader_Invalidoperationexception - Fatal编程技术网

Vb.net 在读卡器关闭时调用NextResult的尝试无效。运动模拟

Vb.net 在读卡器关闭时调用NextResult的尝试无效。运动模拟,vb.net,datareader,invalidoperationexception,Vb.net,Datareader,Invalidoperationexception,这是我的第一个问题,这个问题对我来说就像一场噩梦。。。请帮帮我 我编写了这段代码,当我调用“refresh_data()”子函数时,这个问题就出现了 (“当读卡器关闭时调用NextResult的尝试无效。”) 这是我的密码 Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" & Application.StartupPath & "\MyData.mdb;user id=admin;jet

这是我的第一个问题,这个问题对我来说就像一场噩梦。。。请帮帮我

我编写了这段代码,当我调用“refresh_data()”子函数时,这个问题就出现了

(“当读卡器关闭时调用NextResult的尝试无效。”)

这是我的密码

Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" & Application.StartupPath & "\MyData.mdb;user id=admin;jet oledb:database password=Man_Admin"
Dim Con As New OleDb.OleDbConnection(ConStr)
Dim DS As New DataSet
Dim DS1 As New DataSet
Dim PersonDS As New DataSet
Dim PaysDS As New DataSet
Dim SQLstr As String
    '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    Sub Load_Persons()
        If Con.State = ConnectionState.Open Then Con.Close()
        Con.Open()
        DS.Clear()
        SQLstr = "SELECT Person From Persons"
        Dim DA1 As New OleDbDataAdapter(SQLstr, Con)
        DA1.Fill(DS, "Persons")
        PersonsDGView.DataSource = DS
        PersonsDGView.DataMember = "Persons"
        Con.Close()
        With PersonsDGView.Columns("Person")
            .HeaderText = "اسم الشخص"
        End With
    End Sub
    '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    Sub Load_Person_Detail()
        If Con.State = ConnectionState.Open Then Con.Close()
        Con.Open()
    PersonDS.Clear()
        SQLstr = "SELECT * From Persons Where Person='" & PersonsDGView.CurrentRow.Cells(0).Value & "'"
    Dim DA2 As New OleDbDataAdapter(SQLstr, Con)
    DA2.Fill(PersonDS, "Persons")
        PersonNameTXT.DataBindings.Clear()
        PersonNameTXT.DataBindings.Add("Text", PersonDS, "Persons.Person")
        PhoneNum1Txt.DataBindings.Clear()
        PhoneNum1Txt.DataBindings.Add("Text", PersonDS, "Persons.Phone_Num1")
        PhoneNum2Txt.DataBindings.Clear()
        PhoneNum2Txt.DataBindings.Add("Text", PersonDS, "Persons.Phone_Num2")
        EmailTxt.DataBindings.Clear()
        EmailTxt.DataBindings.Add("Text", PersonDS, "Persons.E-mail")
        Con.Close()
    End Sub
    '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    Sub Load_Pays()
        If Con.State = ConnectionState.Open Then Con.Close()
        Con.Open()
        DS1.Clear()
        SQLstr = "SELECT * From Payment Where Person='" & PersonsDGView.CurrentRow.Cells(0).Value & "'"
    Dim DA3 As New OleDbDataAdapter(SQLstr, Con)
    DA3.Fill(DS1, "Payment")
        PaysDGVIEW.DataSource = DS1
        PaysDGVIEW.DataMember = "Payment"
        Con.Close()
        With PaysDGVIEW.Columns("ID")
            .HeaderText = "رقم الدفعة"
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        End With
        With PaysDGVIEW.Columns("Person")
            .HeaderText = "اسم الشخص"
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        End With
        With PaysDGVIEW.Columns("Date1")
            .HeaderText = "التاريخ"
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        End With
        With PaysDGVIEW.Columns("state")
            .HeaderText = "البيان"
        End With
        With PaysDGVIEW.Columns("Into")
            .HeaderText = "الوارد"
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        End With
        With PaysDGVIEW.Columns("Outgo")
            .HeaderText = "الصادر"
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        End With
    End Sub
    '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    Sub Load_Pays_Details()
        If Con.State = ConnectionState.Open Then Con.Close()
        Con.Open()
        PaysDS.Clear()
        Dim ID As Integer
        ID = PaysDGVIEW.CurrentRow.Cells(0).Value
        SQLstr = "SELECT * From Payment Where ID=" & ID & ""
    Dim DA4 As New OleDbDataAdapter(SQLstr, Con)
    DA4.Fill(PaysDS, "Payment")
        PaymentNameTXT.DataBindings.Clear()
        PaymentNameTXT.DataBindings.Add("Text", PaysDS, "Payment.Person")
        DTP.DataBindings.Clear()
        DTP.DataBindings.Add("Text", PaysDS, "Payment.Date1")
        StateTXT.DataBindings.Clear()
        StateTXT.DataBindings.Add("Text", PaysDS, "Payment.State")
        TotalOfIngo.DataBindings.Clear()
        TotalOfIngo.DataBindings.Add("Text", PaysDS, "Payment.Into")
        TotalOfOutgo.DataBindings.Clear()
        TotalOfOutgo.DataBindings.Add("Text", PaysDS, "Payment.Outgo")
        Con.Close()
        TotalOfPayment2.Text = Val(TotalOfIngo.Text) - Val(TotalOfOutgo.Text)
    End Sub
    '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    Sub add_Total()
        If PaysDGVIEW.Columns.Contains("TotalCol") Then
            PaysDGVIEW.Columns.Remove("TotalCol")
        End If
        PaysDGVIEW.Columns.Add("TotalCol", "المجموع")
        PaysDGVIEW.Columns("TotalCol").AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        For Each r As DataGridViewRow In PaysDGVIEW.Rows
            r.Cells("TotalCol").Value = r.Cells("Into").Value - r.Cells("Outgo").Value
        Next

        Dim TotalRow As DataRow
        TotalRow = DS1.Tables("Payment").NewRow
        Dim sader As Double
        Dim uared As Double
        Dim Count As Integer = (PaysDGVIEW.Rows.Count)

        For s = 0 To PaysDGVIEW.Rows.Count - 1
            sader += PaysDGVIEW.Rows(s).Cells("outgo").Value
        Next
        For u = 0 To PaysDGVIEW.Rows.Count - 1
            uared += PaysDGVIEW.Rows(u).Cells("into").Value
        Next
        With TotalRow
            .Item(0) = 0
            .Item(3) = "المجموع"
            .Item(4) = uared
            .Item(5) = sader
        End With
        DS1.Tables("Payment").Rows.Add(TotalRow)
        DS1.Tables("Payment").AcceptChanges()
        PaysCount.Text = Count
        UaredTotal.Text = uared
        saderTotal.Text = sader
        TotalTotal.Text = uared - sader
    End Sub
    '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    Sub Get_Total()
        For Each r As DataGridViewRow In PaysDGVIEW.Rows
            r.Cells("TotalCol").Value = r.Cells("Into").Value - r.Cells("Outgo").Value
        Next
End Sub
Sub refersh_data()

    Dim DA1 As New OleDbDataAdapter("SELECT Person From Persons", Con)
    DS.Clear()
    DA1.Fill(DS, "Persons") '\\ The Message Shows up in this Line 

    Dim DA2 As New OleDbDataAdapter("SELECT * From Persons Where Person='" & PersonsDGView.CurrentRow.Cells(0).Value & "'", Con)
    PersonDS.Clear()
    DA2.Fill(PersonDS, "Persons")

    Dim DA3 As New OleDbDataAdapter("SELECT * From Payment Where Person='" & PersonsDGView.CurrentRow.Cells(0).Value & "'", Con)
    DS1.Clear()
    DA3.Fill(DS1, "Payment")

    Dim ID As Integer
    ID = PaysDGVIEW.CurrentRow.Cells(0).Value
    Dim DA4 As New OleDbDataAdapter("SELECT * From Payment Where ID=" & ID & "", Con)
    PaysDS.Clear()
    DA4.Fill(PaysDS, "Payment")
End Sub

您是否尝试将适配器(DA1)填充到空数据集?我该怎么做?…我发现了这篇类似的帖子,它可能会给您一些线索。感谢您的回复:但这没有帮助,因为这段代码的一部分容易受到sql注入攻击。这简直是乞求被黑客攻击。