日期:2014-05-18  浏览次数:20772 次

往数据库插入记录问题
页面是这样
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<jsp:useBean   id= "connBean "   class= "beans.connDB "   scope= "page "/>
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
</head>
<%    
        String   wuliao=request.getParameter( "textfield ");
String   pinming=request.getParameter( "textfield2 ");
String   shulian=request.getParameter( "textfield3 ");
String   danjia=request.getParameter( "textfield5 ");
String   jine=request.getParameter( "textfield6 ");
String   jiaoqi=request.getParameter( "textfield4 ");
String   gongyinshang=request.getParameter( "textfield7 ");
String   asql= "insert   into   wuliao(wuliao,pinming,shulian,danjia,jine,jiaoqi,gongyinshang)   values( ' "+wuliao+ ", ' "+pinming+ ", ' "+shulian+ ", ' "+danjia+ ", ' "+jine+ ", ' "+jiaoqi+ ", ' "+gongyinshang+ " ') ";
  int   set=connBean.executeUpdate(asql);
      if(set!=0)
      out.print( "sucsses ");
  %>
<body>
</body>
</html>
运行   可以显示   sucsses   但数据库里没记录   怎么回事呢    


------解决方案--------------------
int set=connBean.executeUpdate(asql);
if(set!=0)
out.print( "sucsses ");
改成
int set=connBean.executeUpdate(asql);
if(set> 0)
out.print( "sucsses ");
查查是不是从1开始的

------解决方案--------------------

String asql= "insert into wuliao(wuliao,pinming,shulian,danjia,jine,jiaoqi,gongyinshang) values( ' "+wuliao+ ", ' "+pinming+ ", ' "+shulian+ ", ' "+danjia+ ", ' "+jine+ ", ' "+jiaoqi+ ", ' "+gongyinshang+ " ') ";

String asql= "insert into wuliao(wuliao,pinming,shulian,danjia,jine,jiaoqi,gongyinshang) values( ' "+wuliao+ " ', ' "+pinming+ " ', ' "+shulian+ " ', ' "+danjia+ " ', ' "+jine+ " ', ' "+jiaoqi+ " ', ' "+gongyinshang+ " ') ";