SQLString:='select * from Table_name where province='+ComboBox1.text+' and city='+ComboBox2.text;

解决方案 »

  1.   

    1. Combobox1.onchange 作第一个查询 
      select * from city from table where province='+combobox1.text
    2. Combobox2.items.clear
    while not eof do begin
      combobox2.items.add(fieldbyname('city').asstring);
      next;
    end;
      

  2.   

    sorry'select * from city where province='+combobox1.text
      

  3.   

    sorry
    ' select city from table where ':-)
      

  4.   

    不对
    selet * from city where province='''+combobox1.text+''''
      

  5.   

    Type
      ....
      private
        procedure ComboboxChange(Sender: TObject);
      .....
    end;
    //------------------------------------  
    TForm1.Form1OnShow(Sender: TObject);
    begin
      with Query1 do  //得到省份
      begin
        Close;
        SQL.Clear;
        SQL.Add('Select * from 省份表');  //得到省份
        Open;
        First
        Combobox1.Clear;
        while not eof do
        begin
          Combobox1.Items.Add(FieldByName('省份').AsString);
          Next;
        end;  
        Close;
      end;  //with  
      //--------------------
      with Query1 do  //得到市
      begin
        Close;
        SQL.Clear;
        SQL.Add('Select * from 市表');  //得到市
        Open;
        First
        Combobox2.Clear;
        while not eof do
        begin
          Combobox2.Items.Add(FieldByName('市').AsString);
          Next;
        end;  
        Close;
      end;  //with  
      
      Combobox1.OnChange:= CoboboxChange;
      Combobox2.OnChange:= CoboboxChange;end;
    //------------------------------------------
    procedure ComboboxChange(Sender: TObject);
    begin
      with Query2 do
      begin
        if (ComboBox1.ItemIndex <> -1) and (ComboBox1.ItemIndex <> -1) then
        begin
          Close;
          SQL.Clear;
          SQL.Add('select * from 要查询的表 where 省份=''' + ComboBox1.Text + 
                  ''' and ' + '市=''' + ComboBox2.text + '''');
          Open;
          //这里设置DataSource,DataSet等属性进行显示即可,略。 
        end; 
      end;end;//query1是临时用的query组件,明白不小弟弟。:)
      

  6.   

    哦,写错了,应该是:
    (ComboBox1.ItemIndex <> -1) and (ComboBox2.ItemIndex <> -1) 
                                            ~~~~~