Reader alreay associated with command error -
12-19-2005
, 01:58 PM
Hello,
I've searched and seen this question posted many times, but all the answers
are about the same and none work for me.
I have 2 SQL commands, and 2 data readers. Here is the code block:
cmd.CommandText = "Select * From ServiceDepartments order By Department"
reader = cmd.ExecuteReader()
while reader.read()
ctr = ctr + 1
Departments(ctr-1) = reader("Department")
DepID(ctr-1) = reader("ID")
'Write the javascript condition for the department
Response.Write (" if (Departments[Departments.selectedIndex].value ==
""" & reader("id") & """) {" & vbcrlf)
'*** PROBLEM HERE!!!
cmd2.commandText = "Select * From Skills Where ServiceDepID = " &
reader("id") & " order By SkillName"
reader2 = cmd2.executeReader()
'DO STUFF WITH Reader2
reader2.Close() 'Reader Closed!
end while
As soon as the code loops the first time on Reader2/Cmd2 I get the following
error:
There is already an open DataReader associated with this Command which must
be closed first.
But there is not an open reader! Ok, "reader" is open, but it is not
associated with cmd2. What am I supposed to be doing here?
Thanks in advance,
Craig |