什么问题,好郁闷,在线等 (0分)

  • 主题发起人 主题发起人 xiaotianwangzi
  • 开始时间 开始时间
X

xiaotianwangzi

Unregistered / Unconfirmed
GUEST, unregistred user!
下面的程序在进行查询的时候抱错,说from语句错,估计是查询语句错了,怎么改
<%@page contentType="text/html;charset=gb2312"%>
<%@page language="java" import="java.sql.*" %>
<jsp:useBean id="hhh" scope="page" class="hyg.faq" />
<HTML>
<HEAD><font size=6 align="center"><h1 align="center">查询界面</h1></font>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=GB2312">
</head>
<body bgcolor="#ccccff">
<table align="center" width="85%" border="1">
<tr><td>用户工号</td><td>用户姓名</td><td>用户性别</td><td>用户年龄</td>
<td>用户文凭</td><td>用户职务</td></tr>
<%!
public String getStr(String str)
{
try
{ String temp_p=str;
byte[] tmpbyte;
tmpbyte=temp_p.getBytes("ISO8859_1");
temp_p=new String(tmpbyte);


return temp_p;
}
catch(Exception e)
{
e.printStackTrace();
}
return "null";
}
%>
<% String ss=new String();
ss=(String)session.getValue("zhiw");
%>
<%
if(!(ss.equals("主任")))
{
%>
<br>对不起,你无权查询</br>
<%
} else
{
%>
<%
String cxtj=new String();
String sql=new String();
String cxgh1=request.getParameter("cxgh");
String cxxm1=request.getParameter("cxxm");
String cxnl1=request.getParameter("cxnl");
String cxtj1=request.getParameter("cxtj1");
String cxxb1=request.getParameter("cxxb");
String cxwp1=request.getParameter("cxwp");
String cxzw1=request.getParameter("cxzw");
cxtj="where ";
if(cxgh1.length()!=0)
{
cxtj=cxtj+"gh='"+cxgh1+"'";
}
if(cxxm1.length()!=0){
cxtj=cxtj+"and xm='"+cxxm1+"'";
}
if((cxtj1.length()!=0)&amp;(cxnl1.length()!=0)){
cxtj=cxtj+"and nl"+cxtj1+"'"+cxnl1+"'";
}
if(cxxb1.length()!=0){
cxtj=cxtj+"and xb='"+cxxb1+"'";
}
if(cxwp1.length()!=0){
cxtj=cxtj+"and wp='"+cxwp1+"'";
}
if(cxzw1.length()!=0){
cxtj=cxtj+"and zhw='"+cxzw1+"'";
}
sql="select * from zgjbxx"+cxtj+"order by gh";
ResultSet rs=hhh.executeQuery(sql);
while(rs.next()){
String gongh=rs.getString("gh");
String xingm=rs.getString("xm");
String xingb=rs.getString("xb");
String nianl=rs.getString("nl");
String zhiw=rs.getString("zhw");
String wenp=rs.getString("wp");
%>
<tr><td><%=gongh%></td><td><%=xingm%></td><td><%=xingb%></td><td><%=nianl%></td>
<td><%=wenp%></td><td><%=zhiw%></td></tr>
<%
}
}
%>
</table>
</body>
</html>
 
please use System.out.println(sql) to see why u get error.
it's a so foolish mistake!!!
i think u need some base skills of debuging.
 
so foolish mistake!!!
代码:
cxtj="where ";
if(cxgh1.length()!=0)
  {
    cxtj=cxtj+"gh='"+cxgh1+"'";
}
  if(cxxm1.length()!=0){
    cxtj=cxtj+"and xm='"+cxxm1+"'";
}
如果第一个if的条件为false则sql语句里就会是“……where and xm = 'XXXX' ……”
 
接受答案了.
 

Similar threads

后退
顶部