Web 下dataReader的循环读取

来源:互联网 发布:macbookpro写作软件 编辑:程序博客网 时间:2024/05/29 19:49

<%
dim sqlWord as String="select top 7 * from news where focusnews=true order by newsid desc"
dim mycmdWord as oledbcommand=new oledbcommand(sqlWord,myconn)
dim myreaderWord as oledbdatareader=mycmdWord.executereader()

%>
<td bgcolor=""  style="WORD-WRAP: break-word" class="news">
<%
 Dim WordNextResult As Boolean = True
 Do Until Not WordNextResult
 Do While myReaderWord.Read() 
%><a href="shownews.aspx?newsid=<%=myReaderWord.item("newsid")%>"><%=myReaderWord.item("title")%></a>&nbsp;&nbsp;
<%
Loop
  WordNextResult = myReaderWord.NextResult()
 Loop
 myReaderWord.close()
%>