String csql="insert into yasj(id,name_t,num,type)values('f','','s')";
do you know?
if this sql is successfully executed, name_t will not be null, but a '' string
modify it as following
String csql="insert into yasj(id,name_t,num,type) values('f',null,'s')";
or
String csql="insert into yasj(id,num,type) values('f','s')";int i=zxsql(csql);
 if (i>0) 
   out.print("成功")!;
   else
    out.print("不成功")!;
 请问这里要怎么样控制,请指教!·!!!!!
how do you design your function zxsql?

解决方案 »

  1.   

    sorrymodify it as following
    String csql="insert into yasj(id,name_t,num,type) values('f',null,'','s')";
    or
    String csql="insert into yasj(id,num,type) values('f','','s')";
      

  2.   

    你在向数据库的表中添加了4个字段,但是你却只提供了三个值哟
    具体如下:insert into yasj(id,,num,type)values('f','d','s')
    或insert into yasj(id,name_t,num,type)values('f','','d','s')
      

  3.   

    the fields count you want to insert must be same as value count
      

  4.   

    哦,
    那个没有关系,
    我多写了一个,但是就像JavaJspServlet()说的一样,
    这个东西insert into yasj(id,name_t,num,type)values('f','','d','s')JSP里他就说添加不成功,
    不明白,但是SQL语句是允许空值的,在JSP里面就不可以,!
      

  5.   

    TO : 阿宝
    public int zxsql(String csql) { 
    int i=0;
    try { 
    Class.forName(DBDriver); 
    }
    catch(java.lang.ClassNotFoundException e) { 
    System.err.println("jdbc for odbc的驱动不存在"); 
    i=0;

    try { 
    cn = DriverManager.getConnection(cnstr); 
    java.sql.Statement st =                   cn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); 
    i=st.executeUpdate(csql);
    }
    catch(SQLException ex) { 
    System.err.println("执行语句错误或连接已断开"); 
    }  return i;
    }    
    %>这个是这样写的
      

  6.   

    to : 阿宝
      speak chinese
      

  7.   

    i am sorry, i can not use chinese in company
    please change ResultSet.CONCUR_READ_ONLY to be ResultSet.CONCUR_UPDATABLE
      

  8.   

    does you table allow your filed to be null?
    i do not understand 不明白,但是SQL语句是允许空值的,在JSP里面就不可以,!
    and 但是现在我必须所有的参数都必须有值,一个为空都不能添加成功!
    what is your 参数, and where and how do you use it in your code?