每执行一句 rs.()next语句,结果集的游表会向下移动一次,所以,你取的三个字段,分别是三条纪录的

解决方案 »

  1.   

    据观察得出结论,由于你的第一个while循环已经把纪录的指针指到了最后,后面两个while当然取不到纪录了
      

  2.   

    hehe,()加错了 是rs.next()
    不好意思
      

  3.   

    while(rst.next()){
      String Ctitle=new String(rst.getString("maintitle")
      String Cdate=new String(rst.getString("date"));
      String Cid=new String(rst.getString("id"));
    }这样就行了
      

  4.   

    正如楼上的朋友所说
    如果要是现你的功能可以先把
    所有的纪录都存放到一个Vector中
    vector的每个元素都是vector,里面存放表中行的内容
    这样就行了,要不你的resultSet每读一次,第二次读时
    把它的游标回到起始位置
      

  5.   

    xuyang821225(CSDN账号) 
    while(rst.next()){
      String Ctitle=new String(rst.getString("maintitle")
      String Cdate=new String(rst.getString("date"));
      String Cid=new String(rst.getString("id"));
    }
    意思是说,我的游标到了最下面吗?是不是这样就不能再回到头上进行再取值了呢?我换成上面的代码,后面还想动态生成<td></td>
    就直接在一个WHILE中做吗?
    我试了一次,还是不行。
    下面这一句有问题吗?
    <input type="text" name="<%=rst.getString("id")%>
    我不知道能不能这样用。
      

  6.   

    <td>  <%try{
    while(rst.next())

    String Ctitle=new String(rst.getString("maintitle"));
    String Cdate=new String(rst.getString("date"));
    String Cid=new String(rst.getString("id"));
    %>
    <%=Ctitle%><br>
       </td>
     <td>   <%=rst.getString("date")%><br>
    </td>
      <td> <form method="post" action=" "> <input type="text" name="<%=rst.getString("id")%>" size="20"><input type="submit" value="提交" name="B1"><br>
    </form><%}
    %> </td>
    我把程序修改为上面的情况,还是同样的提示。
    是不是还有什么地方不合适呢?
      

  7.   

    又改了一次代码,还是不行。代码如下:
     <%try{
    while(rst.next())

    String Ctitle=new String(rst.getString("maintitle"));
    String Cdate=new String(rst.getString("date"));
    String Cid=new String(rst.getString("id"));
    %>
      <td> <%=Ctitle%>

    </td>
     <td>   
    <%=Cdate%>

    </td>
      <td> <form method="post" action=" "><input type="text" name="<%=Cid%>" size="20"><input type="submit" value="提交" name="B1">
    <%}
    %></form></td>