my question is very simple how can I do a nested datareader in my VB code , when i did an error message has been performed and told me "There is already an open DataReader associated with this Command which must be closed first." , please look at the folowing code (is very simple) for information
------------------------vb code-----------------
Dim myConnection As SqlConnection = New SqlConnection("server=ISITC-A31266378;uid=dnnuser40;pwd=1311984;database=DotNetNuke40")
Dim myCommand As SqlCommand
Dim dr As SqlDataReader
'establishing connection. you need to provide password for sql server
myConnection.Open()
'opening the connection
'myCommand = New SqlCommand("SELECT TabName FROM Tabs WHERE ParentId = 69", myConnection)
myCommand = New SqlCommand("SELECT TabName, TabID, ParentID FROM Tabs WHERE ParentId = 63", myConnection)
'executing the command and assigning it to connection
dr = myCommand.ExecuteReader()
While dr.Read()
'reading from the datareader
Response.Write(dr(0).ToString() & " ")
Response.Write(dr(1).ToString() & " ")
Response.Write(dr(2).ToString() & " ")
Dim myCommand2 As SqlCommand
Dim dr2 As SqlDataReader
myCommand2 = New SqlCommand("SELECT TabName FROM Tabs WHERE ParentId = " & dr(1), myConnection)
dr2 = myCommand2.ExecuteReader()
While dr2.Read()
Response.Write(dr2(0).ToString() & " - ")
End While
dr2.Close()
End While
dr.Close()
myConnection.Close()