dualshock03
Well-known member
- Joined
- Jan 28, 2007
- Messages
- 105
- Programming Experience
- 1-3
how to fix this code??
Im always getting an error: " there's already an open datareader associated with this connection which must be close first!"
Im always getting an error: " there's already an open datareader associated with this connection which must be close first!"
VB.NET:
Private Sub btn_VCR_generate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_VCR_generate.Click
con1.Open()
Try
comDate.CommandText = " SELECT * from tblpersonaldata where dateofbirth > '" & dfromvalue.Value & "' AND dateofbirth < '" & dtovalue.Value & "'"
comDate.Connection = con1
SearchAdap.SelectCommand = comDate
readate = comDate.ExecuteReader
While readate.Read
txtsusId.Text = (readate.GetValue(readate.GetOrdinal("accussed_No")))
txtfulname.Text = (readate.GetValue(readate.GetOrdinal("accusedname")))
End While
dtaSet.Clear()
dgrid_view.AutoGenerateColumns = False
dteAdap = New MySql.Data.MySqlClient.MySqlDataAdapter("select * from tblpersonaldata", con1)
dteAdap.Fill(dtaSet, "tblpersonaldata")
DataRecord.Table = dtaSet.Tables("tblpersonaldata")
totalcnt = DataRecord.Count
dgrid_view.DataSource = dtaSet.Tables("tblpersonaldata")
lbltotal.Text = totalcnt
Catch SQL_err As MySql.Data.MySqlClient.MySqlException
MsgBox("Error searching ha database" & SQL_err.Message)
End Try
con1.Close()
End Sub