不知道你的数据库是什么类型的,如果是access的,可以试着把字段设为值允许为空。

解决方案 »

  1.   

    用SQL语句中insert into 表(a,b,c) values(:x,:y,:z),表中可以还有其它字段,但数据库设计时字段设为可以空,如:score表中有字段a,b,c,d,其中d可为空
    with adoquery1 do begin
    close;
    sql.clear;
    sql.add('insert into score(a,b,c) values(:x,:y,:z)');
    parameters.parambyname('x').value:=edit1.text;
    parameters.parambyname('y').value:=edit2.text;
    parameters.parambyname('z').value:=edit3.text;
    execsql;
    end;
      

  2.   

    你说的好象不对,我用的paradox数据库,字段是
    Name a 12
    a是字符串,12是长度
    这样写没有问题
        table1.Edit;
        table1['name']:='';
        table1.Post;而且我也试过了
        table1.Fields[3].Value:='';
    还有
        table1.Fields[3].AsString:='';
    都不会出错,你把你的错误说清楚点,我帮你看。
      

  3.   

    //创建课程表 
    with Table1 do begin
        Active := False;
        DatabaseName :='course';
        TableType := ttParadox;
        TableName := 'course_'+edit1.text;
        with FieldDefs do begin
          Clear;
          with AddFieldDef do begin
            Name := 'date';
            DataType := ftdate;
            Required := True;
           end;
          with AddFieldDef do begin
            Name := 'day';
            DataType := ftInteger;
          end;
          with AddFieldDef do begin
            Name := 'No.1';
            DataType := ftstring;
            Required := True;
            size:=20;
          end;
         //之间省略no.2~no.7,
         with AddFieldDef do begin
            Name := 'No.8';
            DataType := ftstring;
            Required := True;
            size:=20;
          end;
          with IndexDefs do begin
           Clear;
           with AddIndexDef do begin
            Name := '';
            Fields := 'date';
            Options := [ixPrimary];
           end;
          end;
        CreateTable;
        table1.active:=true;
       end;
       end;
      kdate:=strtodate(maskedit1.text);
      i:=strtodate(maskedit1.text);
      jdate:=strtodate(maskedit2.text);
    //循环加入数据
      with table1 do  begin
        while i<=jdate do begin
         begin
           table1.Append;
           table1.edit;
           table1.fields[0].Value:=i;
           if dayofweek(i)<>1 then
              table1.Fields[1].Value:=dayofweek(i)-1
            else
              table1.Fields[1].Value:=7;
           end;
    // 不加‘ss’这些就过不去
           table1.Fields[2].Value:='ss';
           table1.Fields[3].Value:='sss ';
           table1.Fields[4].Value:=' ssss';
           table1.Fields[5].Value:=' ss';
           table1.Fields[6].Value:=' ss';
           table1.Fields[7].Value:='s ';
           table1.Fields[8].Value:='s ';
           table1.Fields[9].Value:='s ' ;
           table1.post;      
           i:=i+1;
         end;
    显示:'field'no.1'must have a value'
      

  4.   

    如netlib(河外孤星)说的情况为什么我做的会出这个问题??谢谢大家帮忙!
      

  5.   

    with AddFieldDef do begin
            Name := 'No.1';
            DataType := ftstring;
            Required := True;  //这个就说明必须有值
            size:=20;