Dim fcs As String
fcs = "select fname,dept from nstudent where stid = '" & txt_sid.Text & "'"
scmd1 = New SqlCommand(fcs, con)
dr = scmd1.ExecuteReader
Dim n As Byte
n = dr.Read
If (n > 0) Then
txt_sname.Text = dr.Item(0)
cmb_dept.Text = dr.Item(1)
If Not dr.IsClosed Then dr.Close()
The above code i have used. if the given input is present it returning otherwise the program exit and displaying the following error.
There is already an open DataReader associated with this Command which must be closed first
pls anyone give the solution..
From what you have posted, it looks like you are not disposing of scmd1,
If you dispose of this after you close the datareader it might solve your problem.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)