Microsoft][ODBC SQL Server Driver][SQL Server]第 1 行: '=' 附近有语法错误。
代码如下。。什么问题呢???<%@pagecontentType="text/html;charset=GB2312"%><%@pageimport="java.sql....
代码如下。。什么问题呢???
<%@ page contentType="text/html; charset=GB2312"%>
<%@ page import="java.sql.*" %>
<html>
<head>
<title>留言记录</title>
</head>
<body>
<% request.setCharacterEncoding("GB2312");
String s_author=request.getParameter("g_author");
if(s_author==null){
s_author="";
}
String s_title=request.getParameter("g_title");
if(s_title==null){
s_title="";
}
String s_content=request.getParameter("g_content");
if(s_content==null){
s_content="";
}
%>
<font size=4 color=bule>留言记录</font><hr>
<%
String driverClass="sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:guestbook";
String username = "sa";
String password = "123456";
String sql;
Class.forName(driverClass);
Connection conn=DriverManager.getConnection(url, username, password);
Statement stmt=conn.createStatement();
try{
sql="Insert Into notes(author,title,content)"+
"Values('"+s_author+"','"+s_title+"','"+s_content+"')";
stmt.executeUpdate(sql);
ResultSet rs = stmt.executeQuery("select * from notes='"+s_author+"'");
%>
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="td">
<tr>
<td width="20%">留言者</td>
<td width="20%">留言标题</td>
<td width="60%">留言内容</td>
</tr>
<%
while(rs.next()){
%>
<tr>
<td><%=rs.getString("author")%></td>
<td><%=rs.getString("title")%></td>
<td><%=rs.getString("content")%></td>
</tr>
<%
}
rs.close();
}
catch(Exception e){
out.println(e.getMessage());
}
stmt.close();
conn.close();
%>
</table> <a href="index.jsp">继续留言</a>
</body>
</html> 展开
<%@ page contentType="text/html; charset=GB2312"%>
<%@ page import="java.sql.*" %>
<html>
<head>
<title>留言记录</title>
</head>
<body>
<% request.setCharacterEncoding("GB2312");
String s_author=request.getParameter("g_author");
if(s_author==null){
s_author="";
}
String s_title=request.getParameter("g_title");
if(s_title==null){
s_title="";
}
String s_content=request.getParameter("g_content");
if(s_content==null){
s_content="";
}
%>
<font size=4 color=bule>留言记录</font><hr>
<%
String driverClass="sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:guestbook";
String username = "sa";
String password = "123456";
String sql;
Class.forName(driverClass);
Connection conn=DriverManager.getConnection(url, username, password);
Statement stmt=conn.createStatement();
try{
sql="Insert Into notes(author,title,content)"+
"Values('"+s_author+"','"+s_title+"','"+s_content+"')";
stmt.executeUpdate(sql);
ResultSet rs = stmt.executeQuery("select * from notes='"+s_author+"'");
%>
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="td">
<tr>
<td width="20%">留言者</td>
<td width="20%">留言标题</td>
<td width="60%">留言内容</td>
</tr>
<%
while(rs.next()){
%>
<tr>
<td><%=rs.getString("author")%></td>
<td><%=rs.getString("title")%></td>
<td><%=rs.getString("content")%></td>
</tr>
<%
}
rs.close();
}
catch(Exception e){
out.println(e.getMessage());
}
stmt.close();
conn.close();
%>
</table> <a href="index.jsp">继续留言</a>
</body>
</html> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询