求解[SQL Server]在将 varchar 值 'null' 转换成数据类型 int 时失败。代码在下面,求各位大神帮帮忙!!!! 15
<body><%Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Stringur1="jdbc:odbc:pxscj";Str...
<body>
<% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String ur1="jdbc:odbc:pxscj";
String user="sa";
String pwd="123456";
String sql="select * from cjb where sno=? and name=? and subject=? and score=?";
PreparedStatement pstmt;
ResultSet rs;
<%request.setCharacterEncoding("utf-8");
String sno=request.getParameter("sno");
String name=request.getParameter("name");
String subject=request.getParameter("subject");
String score=request.getParameter("score");%>
<%Connection con=DriverManager.getConnection(ur1,user,pwd);
pstmt=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
pstmt.setString(1,sno);
pstmt.setString(2,name);
pstmt.setString(3,subject);
pstmt.setString(4,score);
rs=pstmt.executeQuery();
rs.last();
if(rs.getRow()!=0)
{response.sendRedirect("Cjcz.jsp");}
else
{response.sendRedirect("Srcj1.jsp");
}
%>
<%rs.close();
pstmt.close();
con.close(); %>
</body>
</html> 展开
<% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String ur1="jdbc:odbc:pxscj";
String user="sa";
String pwd="123456";
String sql="select * from cjb where sno=? and name=? and subject=? and score=?";
PreparedStatement pstmt;
ResultSet rs;
<%request.setCharacterEncoding("utf-8");
String sno=request.getParameter("sno");
String name=request.getParameter("name");
String subject=request.getParameter("subject");
String score=request.getParameter("score");%>
<%Connection con=DriverManager.getConnection(ur1,user,pwd);
pstmt=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
pstmt.setString(1,sno);
pstmt.setString(2,name);
pstmt.setString(3,subject);
pstmt.setString(4,score);
rs=pstmt.executeQuery();
rs.last();
if(rs.getRow()!=0)
{response.sendRedirect("Cjcz.jsp");}
else
{response.sendRedirect("Srcj1.jsp");
}
%>
<%rs.close();
pstmt.close();
con.close(); %>
</body>
</html> 展开
展开全部
将字段值为null的转成0,
isnull(字段,0)
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |