SQLString:='select * from Table_name where province='+ComboBox1.text+' and city='+ComboBox2.text;
解决方案 »
- delphi2007中能否使用devexpress.xtracharts.chartcontrol
- N个封包的数据流保存成图片
- Forms单元
- 请教半透明的MainMenu及PopupMenu
- 文件传输,单向-->>双向的实现方法???
- findfistfile或findnext获取的文件名问题————简单啊
- 如何实现是否自动启动?
- 怎样可以把网页加入资源文件中,加入了怎样调用?
- 这里非常需要你的建议!(我刚起步)
- 求助:我想用程序重启Win2K![ 遇到了麻烦 ExitWindowsEx 无法实现] 绝对高手请进:!!详情...
- 使用ADOQuery,我往数据库存数据,但不让数据库存相同(二个字段都相同)记录,为什么结果不是我想的??
- 如何显示规定的字段形式?
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;
' select city from table where ':-)
selet * from city where province='''+combobox1.text+''''
....
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组件,明白不小弟弟。:)
(ComboBox1.ItemIndex <> -1) and (ComboBox2.ItemIndex <> -1)
~~~~~