请问这是什么错误(数据源应该没问题)?java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]COUNT 栏位不正确

lci21 2001-06-08 02:02:00
<%@page contentType="text/html;charset=GB2312"%>
<%@page import="java.sql.*,com.convert.Convert"%>
<%@include file="yz.jsp"%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%

String username=request.getParameter("username");
//out.println(username);
String dept=request.getParameter("dept");
String post=request.getParameter("post");
String contents=request.getParameter("contents");
String cmoney=request.getParameter("cmoney");
String timeper=request.getParameter("timeper");
String complete=request.getParameter("complete");
String behave=request.getParameter("behave");
String cdate=request.getParameter("cdate");

username=Convert.getString(username);
dept=Convert.getString(dept);
post=Convert.getString(post);
contents=Convert.getString(contents);
cmoney=Convert.getString(cmoney);
timeper=Convert.getString(timeper);
complete=Convert.getString(complete);
behave=Convert.getString(behave);
cdate=Convert.getString(cdate);
/*
out.println("(userid="+userid+")<br>");
out.println("(dept="+dept+")<br>");
out.println("(post="+post+")<br>");
out.println("(contents="+contents+")<br>");
out.println("(cmoney="+cmoney+")<br>");
out.println("(ctimeper="+timeper+")<br>");
out.println("(complete="+complete+")<br>");
out.println("(behave="+behave+")<br>");
out.println("(cdate="+cdate+")<br>");
out.println("(userid="+userid+")<br>");
*/
%>
<%
if((username.length()==0)||(contents.length()==0))
%>
<script language="vbscript">
msgbox "对不起,姓名和工作内容不得为空!",64,"提交失败"
location.href="javascript:history.back(1)"
</script>
<%
else{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:work_notes";
Connection con=DriverManager.getConnection(url,"lci","");
PreparedStatement insert_stm=con.prepareStatement("insert into notes values(?,?,?,?,?,?,?,?,?,?,?)");

insert_stm.setString(1,userid);

insert_stm.setString(2,dept);
insert_stm.setString(3,cdate);

insert_stm.setString(5,contents);

insert_stm.setString(6,cmoney);
insert_stm.setString(7,timeper);
insert_stm.setString(8,complete);
insert_stm.setString(9,behave);
//insert_stm.setString(9,"dremark");
//insert_stm.setString(10,"remark");
//insert_stm.setString(11,"");
out.println("hi1<br>");

try{
out.println("hi2<br>"); //调试时此处能输出hi2
insert_stm.executeUpdate();
out.println("hi2<br>"); //此处什么也没有输出
}catch(Exception e) {out.println(e);}
//con.close();

%>
<!--
<script language="vbscript">
msgbox "提交成功,谢谢!",64,"提交成功"
location.href="javascript:history.back(1)"
</script>
-->
<%
}catch(Exception e){}
}
%>
<P> </P>

</BODY>
</HTML>
...全文
44 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lci21 2001-06-08
sorry,现在已经解决了,多谢!
错误原因:
PreparedStatement insert_stm=con.prepareStatement("insert into notes values(?,?,?,?,?,?,?,?,?,?,?)");
与后面的参数设置不匹配!
回复
Sylvan 2001-06-08
<%@include file="yz.jsp"%>
这个文件贴出来看看
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2001-06-08 02:02
社区公告
暂无公告