java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
<%!
Connection con= null;
Statement stmt = null;
ResultSet rs;
%>
<%
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
con=DriverManager.getConnection( "jdbc:odbc:jsjdj ");
stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
String itemid=request.getParameter( "id ");
String sql = "select * from Notice where myid= "+itemid+ " ";
rs = stmt.executeQuery(sql);
String title = rs.getString(2) ;
String content = rs.getString(3) ;
%>
<%
while(rs.next())
{
%>
<form action= "update_do.jsp " method= "post " name= "mdfform "
onSubmit= "javaScript: return validateMdf(); ">
<tr>
<td bgcolor= "#cccccc " width= "65 " height= "67 "> 题目: </td>
<td bgcolor= "#cccccc " width= "298 "> <input type= "text " name= "title " height= " "value= " <%=title%> "> </td>
</tr>
<tr>
<td bgcolor= "#cccccc " width= "65 " height= "107 "> 内容: </td>
<td bgcolor= "#cccccc " width= "298 "> <textarea name= "content " cols= "30 " rows= "6 "> <%=content%> </textarea> </td>
</tr>
<tr align= "center " bgcolor= "#996633 ">
<td height= "25 " colspan= "2 "> <input name= "Submit " type= "submit " value= " 提交 ">
<input name= "Submit1 " type= "reset " value= " 重 设 ">
<input name= "id " value= " <%=itemid%> "> </td>
</tr>
</form>
<% }
rs.close();
stmt.close();
con.close();
%>
小妹初学jsp,请高手指教下这是什么原因?
[解决办法]
String sql = "select * from Notice where myid= "+itemid+ " ";
改成
String sql = "select * from Notice where myid= ' "+itemid+ " ' ";
[解决办法]
http://blog.csdn.net/yuyangwxj/archive/2006/06/23/826020.aspx
自己看啦。
你连接不对