我在ComboBox中输入数据,存到表Comp_Pipe_Name的Pipe_Name字段中,存之前想判断一个数据库表里是否里已经存过这个记录,如没存过再存入,判断过程我是在ComboBox1的OnExit事件中触发这个事件:代码如下: 
procedure TInputDlg.ComboBox1Exit(Sender: TObject);
begin
  Result := True;
  with DataModule1.ADOquery1 do
  begin
    close;
    sql.clear;
    sql.add('select * from Comp_Pipe_Name where field =:Pipe_Name');
    parameters.ParamByName('Pipe_Name').value:=combobox1.text;
    open;
  end;
  if DataModule1.ADOquery1.recordcount>0 then
  begin
    Application.messagebox('已经输入过此数据','提示',0+mb_iconquestion)  ;
    combobox1.setfocus;
    combobox1.text:='';
    Result := False;
  end;
下面我想在主程序里调用这个函数(主程序就是用来往数据库的表里存数据的),主程序是这样的:   
end;
begin
    if InputDlg.ShowModal = mrok then
    begin
      Close;
      SQL.Clear;----------------------------------------------
      with DataModule1.ADOQuery1 do
      begin
        if InputDlg.ComboBox1Exit then  ------------------------------
        begin
          SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a)');
          Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text;
        end;
      end;
   end;
end;
编译后提示出错:
[Error] digitizer_main.pas(292): Undeclared identifier: 'SQL'
[Error] digitizer_main.pas(295): Not enough actual parameters
希望高手帮助解答!!!!

解决方案 »

  1.   


    下面我想在主程序里调用这个函数(主程序就是用来往数据库的表里存数据的),主程序是这样的:  
    end; 
    begin 
        if InputDlg.ShowModal = mrok then 
        begin 
          DataModule1.ADOQuery1.Close; 
          DataModule1.ADOQuery1.SQL.Clear;---------------------------------------------- 
          with DataModule1.ADOQuery1 do 
          begin 
            if InputDlg.ComboBox1Exit then  ------------------------------ 
            begin 
              SQL.Add('Insert Comp_Pipe_Name(Pipe_Name) Values(:a)'); 
              Parameters.ParamByName('a').value:= InputDlg.ComboBox1.Text; 
            end; 
          end; 
      end; 
    end;