这是我的第一个问题,这个问题对我来说就像是一场噩梦......请帮帮我
我写了这段代码,当我调用“referh_data()”sub
时出现了这个问题(“关闭阅读器时无效尝试调用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