一部分代码
<%
//连接数据库
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:firstdb";
conn = DriverManager.getConnection(url,"admin3","admin3");
stmt=conn.createStatement();
//实现了一些功能
String sql="select * from songhuodan";
rs=stmt.executeQuery(sql);
while(rs.next()){
.......................................................
........................................................
......................................................
..............................................................
}
//找出 a表中b列的个数,并存放在total中
String sqlCount="select count(b) from a";
Statement stmtCount=conn.createStatement();
ResultSet rsCount=stmtCount.executeQuery(sqlCount);
rsCount.next();
int total=rsCount.getInt(1);
//我的下拉菜单的写法
%>
<td >定单号</td>
<select size="1" name="uid">
<%
while(rs.next()){
for(int i=1;i<=total;i++){
%>
<option value=<%=total %>><%=rs.getString("b")%></option>
<%
}
}
%>
</select>
我的目的是在b列里的全部元组显示在这个下拉菜单里,但是我一运行,在下拉菜单里什么也没有.不知道怎么回事.在线等
[此贴子已经被作者于2007-4-5 19:44:36编辑过]