请我如下写应该怎么改:
SQLCode := ' set rowcount 0 select cata,cata2 from law..Law_Info';
SQL.Add(SQLCode);
open;
if not MyQuery.IsEmpty then
while not MyQuery.Eof do
begin
for i:=0 to ComboBox1.itemindex - 1 do
ComboBox1.AddItem(FieldByName('cata').AsString);
i := i + 1;
end;
另问:如何不让表中查找出来的字段不重复!谢谢各位了!
SQLCode := ' set rowcount 0 select cata,cata2 from law..Law_Info';
SQL.Add(SQLCode);
open;
if not MyQuery.IsEmpty then
while not MyQuery.Eof do
begin
for i:=0 to ComboBox1.itemindex - 1 do
ComboBox1.AddItem(FieldByName('cata').AsString);
i := i + 1;
end;
另问:如何不让表中查找出来的字段不重复!谢谢各位了!
SQL.Add(SQLCode);
open;
if not MyQuery.IsEmpty then
while not MyQuery.Eof do
begin
ComboBox1.AddItem(FieldByName('cata').AsString);
end;select distinct() from
SQLCode := ' set rowcount 0 select cata,cata2 from law..Law_Info';
SQL.Add(SQLCode);
open;
if not MyQuery.IsEmpty then
while not MyQuery.Eof do
begin
for i:=0 to myquery.recordcount-1 do
if DBCom.Items.IndexOf(FieldByName('cata').AsString)<0 then
ComboBox1.Items.add(FieldByName('cata').AsString);
end;
SQLCode := ' set rowcount 0 select cata,cata2 from law..Law_Info';
SQL.Add(SQLCode);
open;
ComboBox.items.clear;
for i:=0 to myquery.recordcount-1 do
if DBCom.Items.IndexOf(FieldByName('cata').AsString)<0 then
ComboBox1.Items.add(FieldByName('cata').AsString);
begin
close;
sql.Clear;
sql.Add('select unitname from T_B_unit');
open; combobox1.Clear;
while not Eof do
begin
combobox1.Items.Add(FieldByName('UnitName').AsString);
next;
end;
end;调试通过
SQL.Add(SQLCode);
open;
ComboBox.items.clear;
for i:=0 to myquery.recordcount-1 do
if Combobox1.Items.IndexOf(FieldByName('cata').AsString)<0 then//有就不加入
ComboBox1.Items.add(FieldByName('cata').AsString);
SQL.Add(SQLCode);
open;
ComboBox1.Items.clear;
if not MyQuery.IsEmpty then
while not MyQuery.Eof do
begin
for i:=0 to myquery.recordcount-1 do
if DBCom.Items.IndexOf(FieldByName('cata').AsString)<0 then
ComboBox1.Items.add(FieldByName('cata').AsString);
end;
試試吧!