简单问题:怎么能列出一个字段中记录不同的记录?(50分)

  • 主题发起人 主题发起人 yuv
  • 开始时间 开始时间
Y

yuv

Unregistered / Unconfirmed
GUEST, unregistred user!
日期
2000-10
2000-10
2000-11
2000-12
怎么才能在listbox或ComboBox只列出2000-10,2000-11,2000-12(即唯一不同的),并且
随着日期字段的变化而变化。
当选中listbox或ComboBox中的一个,如2000-10,把日期是2000-10的筛选出来,其他的记录过滤掉。
大侠们帮忙解决!!!
 
query1: select distinct 日期 from tablename
combobox1.itemes.clear;
with query1 do
while not eof do
begin
combobox1.itemes.add(datetostr(rq));
next;
end;

onchange:
select * from tablename where rq:=rq
parambyname('rq').asdate:=strtodate(combobobx1.text);
 

query1.close;
query1.sql.text:='select distinct 字段名 from table';
query1.open;
query1.first;
if is query1.isempty then exit;
combobox1.clear;
while not eof do
begin
combobox1.items.add(query1.fields[0].asstring);
query1.next;
end;
在onchange事件中
query.close;
query.sql.text:='select * from table where date='2001-11';
query1.open;
 
select distinct yourdate from yourtable 取得日期放入combobox
在combobox的onchange事件里写查询,select * from yourtable where yourdate=strToDateTime(combobox.text)

 
明白了,谢谢大家
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部