怎样将页面中下拉框的内容与数据库某列关联 <select name="<%= selectname %>" onChange="<%= onchange %>"> <option value="<%=part_id%>" selected><%=part_name%> // 写个循环,内容从数据库中取.</option> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你一个程序,我自己编的,可以将数据库中的某一列的数据写在下拉框里。<html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body><%String url=new String();String user= new String();String password = new String();url="jdbc:odbc:test";user="sa";password="****"; //该出为密码Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection con= DriverManager.getConnection(url,user,password);Statement stmt = con.createStatement();String SQL = new String();SQL = "SELECT * FROM tablename";ResultSet rs = stmt.executeQuery(SQL);String nm= new String();%><select name="aaa"><% while (rs.next()) { nm= rs.getString("某一列的字段名");%> <option value="<%=nm%>"><% out.println(nm);}rs.close();stmt.close();con.close();%></select></body></html> 你这样写死String 字段了!你应该包装好![email protected] spring 整合jbpm 求大神看一眼异常 疑惑的一点,视频网站诸如优酷土豆等是如何存储海量视频数据的? java长传问题,输入输出流 struts2、Hibernate、Spring整合小问题 分布式数据同步的问题!!很急在线等!! 请问:我在对数据库进行修改删除时,出现奇怪错误,一直无法找到解决办法,在此请朋友给与帮助!!! 不同数据库之间的编码问题是否一样 十万火急,大家帮我看看 JSCRIPT 问题 java中数据库操作小问题 Sun ONE Studio VS jbuilder JDBC与TOMCAT的问题
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body>
<%
String url=new String();
String user= new String();
String password = new String();
url="jdbc:odbc:test";
user="sa";
password="****"; //该出为密码
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con= DriverManager.getConnection(url,user,password);
Statement stmt = con.createStatement();
String SQL = new String();
SQL = "SELECT * FROM tablename";
ResultSet rs = stmt.executeQuery(SQL);
String nm= new String();
%>
<select name="aaa">
<%
while (rs.next()) {
nm= rs.getString("某一列的字段名");
%>
<option value="<%=nm%>">
<%
out.println(nm);
}
rs.close();
stmt.close();
con.close();
%>
</select></body></html>