我尝试这段代码这是在mssqlserver中传递值的问题我将值传递给另一页中的页面听到nrno是值来到其他页面但是听到错误是java.sql.SQLException:无效的列名' nrno”。sql server datainsert错误
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%
String AppURL = request.getContextPath() ;
String thisFile = AppURL+request.getServletPath() ;
int nrno = 0;
try
{
nrno = Integer.parseInt(request.getParameter("rno"));
}
catch(NumberFormatException ex)
{
nrno = 0;
}
%>
<td>this is in roolno :- <%=nrno%> </td><br>
<%
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/sample", "sa", "sa1234");
java.sql.Statement stmt = conn.createStatement();
try
{
int val = stmt.executeUpdate("INSERT student (name,rno) VALUES('nikki',+ nrno)");
out.println("1 row affected");
}
catch (SQLException s)
{
System.out.println("SQL statement is not executed!");
}
stmt.close();
conn.close();
%>
</body>
</html>
PSL使用代码格式化 – KB22 2009-11-09 11:33:30