20-11-15, 08:14 PM
السلام عليكم ورحمة الله وبركاته
عندي مشكلة في وهي الرساله هاي
There is already an open DataReader associated with this Command which must be closed first.
من خلال البحث لما بظغط على زر البحث ممتاز بس لمره واحده فقط
لما ابحث عن سجل ثاني تظهرلي هي الرساله .
هذا كود الزر :
وهذا الكود الي يظهرلي فيه الخطأ
da.Fill(ds, "Streets")
هنا الخطأ على هذا السطر
عندي مشكلة في وهي الرساله هاي
There is already an open DataReader associated with this Command which must be closed first.
من خلال البحث لما بظغط على زر البحث ممتاز بس لمره واحده فقط
لما ابحث عن سجل ثاني تظهرلي هي الرساله .
هذا كود الزر :
كود :
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
comm = New SqlCommand("SELECT * FROM MonitoringReports WHERE EmployeeID = '" & TextBox9.Text & "' and LicensesNumber='" & TextBox1.Text & "'", con)
reader = comm.ExecuteReader
If reader.Read = True Then
TextBox8.Text = reader(0).ToString
TextBox9.Text = reader(1).ToString
DateTimePicker2.Value = reader(2).ToString
TextBox1.Text = reader(3).ToString
TextBox2.Text = reader(4).ToString
TextBox5.Text = reader(5).ToString
ComboBox6.Text = reader(6).ToString
ComboBox1.Text = reader(7).ToString
ComboBox2.Text = reader(8).ToString
TextBox3.Text = reader(9).ToString
ComboBox3.Text = reader(10).ToString
ComboBox7.Text = reader(11).ToString
ComboBox5.Text = reader(12).ToString
TextBox4.Text = reader(13).ToString
DateTimePicker1.Value = reader(14).ToString
reader.Close()
Else
MsgBox("الـرخـصـة الـمـطـلـوبـة غـيـر مـوجـودة", MsgBoxStyle.Critical, "خـــطـــأ")
reader.Close()
End If
End Sub
وهذا الكود الي يظهرلي فيه الخطأ
كود :
Protected Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim da As New SqlDataAdapter("select * From Streets Where LocationID=" & Val(ComboBox1.SelectedValue), con)
Dim ds As New DataSet
da.Fill(ds, "Streets")
ComboBox2.DataSource = ds.Tables("Streets")
ComboBox2.DisplayMember = "StreetName"
End Sub
da.Fill(ds, "Streets")
هنا الخطأ على هذا السطر