主题:那位高手伴我看看这个程序
<%@page pageEncoding="GB2312"%>
<%@page contentType="text/html; charset=gb2312"%>
<%request.setCharacterEncoding("gb2312");%>
<html>
<style type="text/css">
<!--
body {
background-image: url(img/bg1.gif);
}
.STYLE1 {font-size: 12px}
.STYLE4 {color: #B9B9BA}
-->
</style>
<BODY topMargin=120>
<%@ page language="java" import="java.sql.*"%>
<%
String name=request.getParameter("name");
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=try";
//pubs为你的数据库的
String user="sa";
String password="123";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
PreparedStatement stat=conn.prepareStatement("select * from tb_teacher where name=?");
stat.setString(1,name);
ResultSet result=stat.executeQuery();
if(result.next())
{
PreparedStatement newstat=conn.prepareStatement("delete from tb_teacher where name=?");
newstat.setString(1,name);
newstat.executeUpdate();
out.println("<B><p> </p><p> </p><P align=center>你已经成功删除此教师信息</P></B>");
}
else
{
out.println("<B><p> </p><p> </p><P align=center>删除失败</P></B>");
}
}
catch(Exception e)
{
out.println(e);
}
%>
<P align=center><A href="jiaoshixinxi.jsp">返回</A>
</html>
<%@page contentType="text/html; charset=gb2312"%>
<%request.setCharacterEncoding("gb2312");%>
<html>
<style type="text/css">
<!--
body {
background-image: url(img/bg1.gif);
}
.STYLE1 {font-size: 12px}
.STYLE4 {color: #B9B9BA}
-->
</style>
<BODY topMargin=120>
<%@ page language="java" import="java.sql.*"%>
<%
String name=request.getParameter("name");
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=try";
//pubs为你的数据库的
String user="sa";
String password="123";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
PreparedStatement stat=conn.prepareStatement("select * from tb_teacher where name=?");
stat.setString(1,name);
ResultSet result=stat.executeQuery();
if(result.next())
{
PreparedStatement newstat=conn.prepareStatement("delete from tb_teacher where name=?");
newstat.setString(1,name);
newstat.executeUpdate();
out.println("<B><p> </p><p> </p><P align=center>你已经成功删除此教师信息</P></B>");
}
else
{
out.println("<B><p> </p><p> </p><P align=center>删除失败</P></B>");
}
}
catch(Exception e)
{
out.println(e);
}
%>
<P align=center><A href="jiaoshixinxi.jsp">返回</A>
</html>