ywx
发贴: 6
|
于 2006-06-18 23:30
a.jsp: <a href="b.jsp?ID=<%=ID%>">删除</a> b.jsp: <%!String ID; %> <%!Connection connsafe;//定义数据库连接对象 %> <%!Statement stmt;//定义SQL语句对象 %> <% request.setCharacterEncoding("gb2312"); ID=request.getParameter("ID").trim(); try{ String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver"; Class.forName(sDBDriver); String sConnStr="jdbc:odbc:safe"; String userid="sa"; String password=""; Connection connsafe=DriverManager.getConnection(sConnStr,userid,password); stmt=connsafe.createStatement(); String sql="DELETE FROM menu WHERE ID='"+ID+"'"; stmt.executeUpdate(sql); out.println("<font size=3 color=blue>正在删除数据,请稍后......</font><meta http-equiv='refresh' content='2;url=a.jsp'>"); stmt.close(); connsafe.close(); } catch(Exception e){ response.sendRedirect("a.jsp"); } %>
|