procedure SetCmbDict2(myComBox: TComboBox; iDictEntry :integer;iDictEntry2 :integer);
var
  MyQuery :TAdoQuery;
  SQLCode,StrTemp: string;
  i: integer;
begin
  try
    MyQuery:= TadoQuery.Create(nil);
    try
      with MyQuery do
      begin
        Connection := Adocon;
        if Active then Close;
        SQL.Clear;
        SQLCode := ' set rowcount 0 select subentry,dict_entry, dict_prompt'
                 + ' from run..dictionary '
                 + ' where dict_entry = ' + IntTostr(iDictEntry)
                 + ' or  dict_entry = ' + IntTostr(iDictEntry2)
                 + ' and subentry != -1 '
                 + ' and access_level != 3 '
                 + ' order by subentry';
        SQL.Add(SQLCode);
        Open;
        if not MyQuery.IsEmpty  then
        begin
          with myComBox do
          begin
            Items.Clear;
            for i := 0 to MyQuery.RecordCount - 1 do
            begin
              strTemp := FieldByName('dict_entry').Asstring + '.' + FieldByName('subentry').Asstring + '.' + FieldByName('dict_prompt').AsString;
              myComBox.Items.Add(strTemp);
              myComBox.ItemIndex :=0;
              MyQuery.Next;
            end;
          end;
        end;
      end;
    except
      MyQuery.Free;
    end;
  finally
    MyQuery.Free;
  end;
end;
请各位高手帮我看看错在那里?

解决方案 »

  1.   

    except处应该假
            on e:EDatabaseError do
            begin
                if Application.MessageBOx('操作发生错误,是否显示错误信息?', '发生错误', mb_YesNo + mb_IconInformation ) = mrYes then
                    Application.MessageBox( PChar(e.Message), '错误信息', mb_Ok + mb_IconInformation );
                Result:=false;
                exit;
            end;
      

  2.   

    我已经试过了不行
    有谁可以帮我看看SQL语句部分有没有错!
      

  3.   

    我编译的时候提示错误是这样的:[Error] LawSearchTotal.pas(174): Undeclared identifier: 'SetCmbDict2'
      

  4.   

    没有声明
    procedure SetCmbDict2(myComBox: TComboBox; iDictEntry :integer;iDictEntry2 :integer);
    在有procedure的地方 或 private
        { Private declarations }或
      public 后
    加上
      

  5.   

    IORILI(近视眼@_@) 谢谢,我问题解决了!呵呵!各位太感谢你们了!
      

  6.   

    要判断SQL语句有没有问题,可以在OPen之前加Memo1.lines.add(sql.code); exit;
    语句,然后执行,把Memo1在的文本复制到可以执得SQL语句的工具中,问题就很容易解决了
      

  7.   

    你的setCmbDict2是在哪个窗体中的? 
    procedure 窗体名.SetCmbDict2(myComBox: TComboBox; iDictEntry :integer;iDictEntry2 :integer);
    你地过程中引用了一个窗体中的adoconn吧. 如果想写一个单独的过程,干脆连adoConn也传进来吧.