?? search_do.jsp
字號:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>查找信息</title>
</head>
<body>
<table width="595" border="1" align="center">
<tr>
<td width="173"><div align="center">ID</div></td>
<td width="176"><div align="center">物料號</div></td>
<td width="199"><div align="center">物料</div></td>
<td width="199"><div align="center">數量</div></td>
<td width="199"><div align="center">單價</div></td>
</tr>
<%
request.setCharacterEncoding("GB2312");
String schtxt=request.getParameter("schtxt");
String sel=request.getParameter("sel");
//out.println(schtxt);
//out.println(sel);
String className="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String url="jdbc:sqlserver://localhost:1433;DatabaseName = scm";
String user="sa";
String password="000000";
try{
Class.forName(className);
Connection con=DriverManager.getConnection(url,user,password);
Statement stat=con.createStatement();
// String sql="select userName,pass from user";
String sql="select * from t_orderitem where "+sel+" like '%"+schtxt+"%'";
// select * from book where bookName like '%的%';
//out.println(sql);
ResultSet rs=stat.executeQuery(sql);
if(rs.next())
{
out.println("<tr><td><center>"+rs.getInt(1)+"</center></td>");
out.println("<td><center>"+rs.getString(2)+"</center></td>");
out.println("<td><center>"+rs.getString(3)+"</center></td>");
out.println("<td><center>"+rs.getInt(4)+"</center></td>");
out.println("<td><center>"+rs.getInt(5)+"</center></td></tr>");
}
else
{
out.println("查找目標不存在");
}
rs.close();
stat.close();
con.close();
}
catch(ClassNotFoundException e)
{out.println(e.toString());}
catch(SQLException e)
{out.println(e.toString());}
%>
</table>
<div align="center"><br><font color="#0080ff"><a href="javascript:history.go(-1);">點擊返回上一頁</a></font></div>
</div></body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -