补充一下:query_contract中的记录是用append的方法填加,然后让用户输入数据

解决方案 »

  1.   

    if_located := Query_contract.Locate('user_id', DBE_user_id.Text, []);
          有问题
    use other ttable replace Query_contract
      

  2.   

    我必须用tquery的,要不没办法做的
      

  3.   

    mysql:=Tquery.create(nil);
    with mysql do
    begin
      databasename:=Yourdatabasename;
    end;
    try
        Query_contract.First;
        //Query_contract.Bof
        while not Query_contract.Eof do
        begin
           with mysql do
           begin
              close;
              sql.clear;
              sql.add(format('select user_id from yourtablename where userid=''%s'',[DBE_user_id.Text]));
            open;
             if_located:=not (bof and eof);
          end;
     
          if if_located then
          begin
            if (Query_contract.FieldByName('service_id').Text = '') or
              (Query_contract.FieldByName('service_number').Text = '') or
              (Query_contract.FieldByName('ratio').Text = '') then
            begin
              ShowMessage('表中有数据为空!');
              break;
            end;
          end;      Query_contract.Next;
        end;  except  end;
      

  4.   

    try
      if_located := Query_contract.Locate('user_id', DBE_user_id.Text, []);
    except
    end;真是胡闹!!!
    我帮你改改,但只是一种提示性的:
    Query_contract.GetBook(myBook);//请先把当前记录的位置记下来。
    try
      try
        if_located := Query_contract.Locate('user_id', DBE_user_id.Text, []);
        //这一句将可能会改变当前记录的位置,比如又移到第一条,那么先生,这会导致死循环的。
      except
      end;
    finally
      Query_contract.GotoBook(myBook);
      //为了避免当前记录位置被改,请把先前保存的位置还原回去。
    end;      
      

  5.   

    思路错误--循环+locate
    这里:if_located := Query_contract.Locate('user_id', DBE_user_id.Text, []);