datareader嵌套的问题
想实现先从表中查询出记录列,将列值作为参数在循环内部继续查询,如下代码,这在asp当中很常见,现在不灵了,请问错在哪里?该如何嵌套使用datareader
Sub show1
Dim queryString As String = "select bumen from workflo2_bumen order by paixu "
Dim queryString1 As String
Using connection As New OdbcConnection( "DSN=yuangongyingxiao;uid=yuangongyingxiao;pwd=yuangongyingxiao77** ")
Dim command As New OdbcCommand(queryString, connection)
connection.Open()
Dim reader As OdbcDataReader = command.ExecuteReader()
While reader.Read()
'response.write(reader.getString(0)& " | "&reader.getString(1) & " <br> ")
response.Write( " <tr> ")
response.Write( " <td align= " "center " " nowrap style= " "border-bottom:1px dotted #8A9DC6;border-left:1px dotted #8A9DC6;border-right:1px dotted #8A9DC6 " "> <a href= " "huizhi.asp " "> <font color= " "#FFFFFF " "> " & reader.getString(0) & " </font> </a> </td> ")
queryString1 = "select count(g_lanshoudanwei) from workflo2_guhua where g_lanshoudanwei= ' " & reader.getString(0) & " ' and n1_daodashijian > = ' "& DateLimit_1 & " ' and n1_daodashijian <= ' "& DateLimit_2 & " ' and g_jungongshijian is not null "
Dim command1 As New OdbcCommand(queryString1, connection)
Dim reader1 As OdbcDataReader = command1.ExecuteReader()
While reader.Read()
response.Write(reader1.getString(0))
guhua = guhua + reader1.getString(0)
End While
reader1.Close()
response.Write( " <td align= " "right " " nowrap style= " "border-bottom:1px dotted #8A9DC6;border-right:1px dotted #8A9DC6 " "> </td> ")
response.Write( " <td align= " "right " " nowrap style= " "border-bottom:1px dotted #8A9DC6;border-right:1px dotted #8A9DC6 " "> </td> ")
response.Write( " <td align= " "right " " nowrap style= " "border-bottom:1px dotted #8A9DC6;border-right:1px dotted #8A9DC6 " "> </td> ")
response.Write( " <td align= " "right " " nowrap style= " "border-bottom:1px dotted #8A9DC6;border-right:1px dotted #8A9DC6 " "> </td> ")
response.Write( " <td align= " "right " " nowrap style= " "border-bottom:1px dotted #8A9DC6;border-right:1px dotted #8A9DC6 " "> </td> ")
response.Write( " <td al