主题:用DBCombobox 选表中某一字段的不重复记录,为什么总是出错
procedure Tjlck.DBComboBox1DropDown(Sender: TObject);
begin
// 原理:利用xhpzQuery获取不重复数据记录
// 将数据一条一条传入到Combobox中
with xhpzquery do
begin
if xhpzquery.active then
xhpzquery.Close;
xhpzquery.SQL.Clear;
xhpzquery.SQL.Add('select distinct 型号配置 * from kczb');
xhpzquery.ExecSQL ;
end;
if xhpzquery.recordcount>0 then
begin
showmessage(' xhpzquery.recordcount>0');
DBComboBox1.Items.clear;
xhpzquery.open;
DBComboBox1.Items.clear;
xhpzquery.First;
while not xhpzquery.Eof do
begin
DBComboBox1.Items.Add(xhpzquery.FieldByName('型号配置').AsString);
xhpzquery.Next;
end;
end;
end;
begin
// 原理:利用xhpzQuery获取不重复数据记录
// 将数据一条一条传入到Combobox中
with xhpzquery do
begin
if xhpzquery.active then
xhpzquery.Close;
xhpzquery.SQL.Clear;
xhpzquery.SQL.Add('select distinct 型号配置 * from kczb');
xhpzquery.ExecSQL ;
end;
if xhpzquery.recordcount>0 then
begin
showmessage(' xhpzquery.recordcount>0');
DBComboBox1.Items.clear;
xhpzquery.open;
DBComboBox1.Items.clear;
xhpzquery.First;
while not xhpzquery.Eof do
begin
DBComboBox1.Items.Add(xhpzquery.FieldByName('型号配置').AsString);
xhpzquery.Next;
end;
end;
end;