读书人

两次while Dr.read()有关问题

发布时间: 2012-02-23 22:01:34 作者: rapoo

两次while Dr.read()问题
<%
Dim Str As String
Dim Sql As String
Dim Dr As OleDbDataReader
Dim Cnn As OleDbConnection
Dim Cmd As OleDbCommand
Dim Sql1 As String
Dim Cmd1 As OleDbCommand
Dim Dr1 As OleDbDataReader
Str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath( "dbhql/bbs.mdb ")
Cnn = New OleDbConnection(Str)
Cnn.Open()
Sql = "select LB from LB "
Cmd = New OleDbCommand(Sql, Cnn)
Dr = Cmd.ExecuteReader()
%>
<table align=left width= "760 " border= "1 " bordercolordark= "#33ccff " bgcolor= "#ffcccc ">
<%While Dr.read() %>
<tr>
<td background= "images/tb.gif " align= "left " style= "height: 27px ">
<a href= "bbs.aspx?LB= <%=Dr.GetString(0)%> "> <font color= "#861E1E " style= "font-size:12px "> ▒ <%=Dr.GetString(0)%> ▒ </font> </a>
</td>
</tr>

<tr>
<td style= "height: 50px ">
<table width= "760 " align= "left " border= "0 " bordercolordark= "#ff0033 " bordercolor= "#99cc99 ">
<tr bgcolor=floralwhite>
<td style= "width: 63px; height: 16px ">
</td>


<td style= "width: 245px; height: 16px ">
论坛 </td>
<td style= "width: 69px; height: 16px ">
主题 </td>
<td style= "width: 70px; height: 16px ">
文章 </td>
<td style= "width: 200px; height: 16px ">
最后发表 </td>
<td style= "height: 16px ">
版主 </td>
</tr>
<%
Sql1 = "select LB,LB1,(select count(title) from Coment),(select count(*) from Coment),Title,BanZhu,FlagPic,Time from Coment where LB= 'Dr.GetString(0) ' "
Cmd1 = New OleDbCommand(Sql1, Cnn)
Dr1 = Cmd1.ExecuteReader()%>
<%While Dr1.Read()%>
<tr>


<td style= "width: 63px; height: 16px ">
<img src= "images/forum_nonews.gif "/> </td>
<td style= "width: 245px; height: 16px ">
<%=Dr1.GetString(1)%>
</td>
<td style= "width: 69px; height: 16px ">
<%=Dr1.GetInt32(2)%>
</td>
<td style= "width: 70px; height: 16px ">
<%=Dr1.GetInt32(3)%>
</td>
<td style= "width: 200px; height: 16px ">
<%=Dr1.GetString(4)%>
</td>
<td style= "height: 16px ">
<asp:DropDownList ID= "Drop1 " runat= "server ">
<asp:ListItem Selected= "True "> 版主列表 </asp:ListItem>


</asp:DropDownList>
<%Drop1.Items.Add(IIf(IsDBNull(Dr1( "BanZhu ")), " ", Dr1( "BanZhu ")))%>
</tr>
<%End While%>
<% Dr1.Close()%>
</table>
</td>
</tr>
<%End While%>
<% Dr.Close()%>
</table>


这当中Sql1 = "select LB,LB1,(select count(title) from Coment),(select count(*) from Coment),Title,BanZhu,FlagPic,Time from Coment where LB= 'Dr.GetString(0) ' "
查询会没有呢?????也就是说Dr.GetString(0)没有接收到??


[解决办法]
Cmd = New OleDbCommand(Sql, Cnn)
Cmd1 = New OleDbCommand(Sql1, Cnn)

问题在这里,你两条查询语句都使用同一个Cnn
连接字符串每次都一样的,所以问题不是在这里!
[解决办法]
学习

读书人网 >asp.net

热点推荐