我嘗試這段代碼這是在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