皇色 小说,信息港,王波 叙利亚
话不多说,直接上例子
insert
string sql="insert into allorder values('" + orderid + "','" + bookid +"','" + amount + "','" + username + "')";
int result=stmt.executeupdate(sql);
if(result==1)
response.sendredirect("index.jsp");
else
response.sendredirect("detail.jsp");
delete
string condition="delete from allorder where id='"+ orderid+ "'";
int result=stmt.executeupdate(condition);
if(result==1)
response.sendredirect("index.jsp");
else
out.println("shopcar.jsp");
update
与delete,insert差不多
select
[code]
<%
while (rs.next()){
string amount=rs.getstring("amount");
string orderid=rs.getstring("id");
string bookname=rs.getstring("name");
string price=rs.getstring("price");
string picture=rs.getstring("pic");
//out.println("\tshuliang"+amount);
%>
<tr><td><%=orderid %></td><td><%=picture %></td><td><%=bookname %></td><td><%=price %></td><td><%=amount %></td><td><table><tr><td><input type="button" value="删除" onclick="window.location.href='delete.jsp?orderid=<%=orderid %>'"></td></tr></table></td></tr>
<%
}
// 关闭连接
stmt.close();// 关闭命令对象连接
con.close();// 关闭数据库连接
} catch (sqlexception e) {
e.printstacktrace();
out.println("数据库连接错误");
system.exit(0);
}
//数据库连接完成
%>
</table>
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
网友评论