27-06-16, 10:40 PM
توجد لدي مشكلة بسيطة
اثناء عملية البحث من تاريخ لتاريخ معين عندما اختار اكثر من مرة لتاريخ حتى يقوم بإعطائي المبلغ الذي تم كسبه في هذة المدة البرنامج يغلق وهذا الخطا يظهر لي
الكود
مكان الخطأ
اثناء عملية البحث من تاريخ لتاريخ معين عندما اختار اكثر من مرة لتاريخ حتى يقوم بإعطائي المبلغ الذي تم كسبه في هذة المدة البرنامج يغلق وهذا الخطا يظهر لي
كود :
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll
Additional information: The connection was not closed. The connection's current state is open.
كود :
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim cmd As New OleDbCommand("Select * From Rent Where Rent_Date >= @Date1 and Rent_Date <= @Date2", con)
cmd.Parameters.Add("@Date1", OleDbType.Date).Value = DateTimePicker1.Value
cmd.Parameters.Add("@Date2", OleDbType.Date).Value = DateTimePicker2.Value
Dim da As New OleDbDataAdapter(cmd)
con.Open()
Dim dt As New DataTable
da.Fill(dt)
Me.DataGridView1.DataSource = dt
Dim txtTotal As Integer
For Each rw As DataGridViewRow In DataGridView1.Rows
txtTotal += CInt(rw.Cells(8).Value)
Next
Label4.Text = txtTotal
End Sub
كود :
con.Open()