各位大虾好,问题如下:
  我在完成数据库输入过程中,要求判断表中如果已有该字段的对应记录,只需将当前数字与表中数字相加即可,单我不知道sql中的edit.text怎么用我的代码如下:
 vari:integer;
shuliang,
strsql,
strshuliang,
strbianhao:string;
begin
  with query1 do
  begin
    query1.Close;
    query1.SQL.Clear;
    strsql:='select bianhao,shuliang from huowu';
    query1.SQL.Add(strsql);
    query1.open;
      begin
      strbianhao:=query1.FieldValues['bianhao'];
      strshuliang:=query1.FieldValues['shuliang'];
      if strbianhao=edit6.text then
      begin
      i:=strtoint(edit4.text);
      shuliang:=inttostr(i+strtoint(strshuliang));
      with query2 do
        begin
          query2.Close;
          query2.SQL.Clear;
          query2.SQL.Add('update huowu set shuliang=:shuliang');
          query2.SQL.Add('where bianhao=+'''+edit6.text);
          query2.Params[0].datatype:=ftstring;
          query2.ParamByName('shuliang').AsString:=shuliang;
          query2.ExecSQL;
          query2.close;
          query2.SQL.Clear;
          end;
判断的代码能实现,可是更新出错,请大家帮忙

解决方案 »

  1.   

    query2.SQL.Add('where bianhao=+'''+edit6.text+''');
      

  2.   


      query2.SQL.Add('where bianhao=+'+''''+edit6.text+'''');//引号的使用
      

  3.   

    query2.SQL.Add('where bianhao='+''''+edit6.text+'''');//把等于号后面的加法号去掉
      

  4.   

    query2.SQL.Add('where bianhao=+'''+edit6.text+''');
      

  5.   

    'WHERE bianhao = ''' + Edit6.Text + '''
      

  6.   

    'WHERE bianhao = ''' + Edit6.Text + '''
      

  7.   

    首先,query1.open;之后尽量用一个.first
    query2.SQL.Add('where bianhao='+''''+edit6.text+'''');
    要四个引号