implementation{$R *.dfm}
var
temp:tstringlist;procedure TForm1.ComboBox2Change(Sender: TObject);
var
sql:string;
begin
sql:='select * from '+combobox2.Text;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(sql);
adoquery1.ExecSQL;
adoquery1.Active:=true;
temp.clear;
adoquery1.Fields.GetFieldNames(temp);
combobox3.Clear;
combobox3.Items.AddStrings(temp);
temp.free;
combobox3.Text:=combobox3.Items[0];
end;
当第一次改变combobox2时,没有出现错误,可是第二改变时就在temp.clear处提示出错,如果去掉这一句则下一句就出错,真搞明白,高手帮忙!谢谢!
var
temp:tstringlist;procedure TForm1.ComboBox2Change(Sender: TObject);
var
sql:string;
begin
sql:='select * from '+combobox2.Text;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(sql);
adoquery1.ExecSQL;
adoquery1.Active:=true;
temp.clear;
adoquery1.Fields.GetFieldNames(temp);
combobox3.Clear;
combobox3.Items.AddStrings(temp);
temp.free;
combobox3.Text:=combobox3.Items[0];
end;
当第一次改变combobox2时,没有出现错误,可是第二改变时就在temp.clear处提示出错,如果去掉这一句则下一句就出错,真搞明白,高手帮忙!谢谢!
解决方案 »
- 求助:报表中令人困惑的1899年问题
- 我从数据库中提取出两个数,如何将两个字符型的变为数字型的然后相加得出个结果,30分
- 三层数据库打包的问题。
- 如何treeview中插入节点?
- fastreport中的系统变量column #总是为1?
- 我想在程序中设 Ctrl+'+'和 Ctrl+'-' 快捷键某些方面,请问代码如何写了?
- 如何改变TEdit,TComboBox控件Enabled:=False时字体颜色(不用控件)
- 各位大侠,帮个忙!!
- 集合类型中的常量怎样才能用汉字呢?如Type Trec=(姓名,性别...)
- 有没有电脑上使用的虚拟传真机?学习APRO控件用到
- 菜鸟,请教各位高手,帮忙看看这段程序,不够再加~~~~~~~感激!!
- 如何改写以下c语句到DELPHI?
不会也帮我顶一下,顶者有分!
adoquery1.Active:=true;====>
adoquery1.Open;
var
sql:string;
begin
sql:='select * from '+combobox2.Text;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(sql);
adoquery1.ExecSQL;
adoquery1.Active:=true;
temp := TStringList.create;--加上这个
temp.clear;
adoquery1.Fields.GetFieldNames(temp);
combobox3.Clear;
combobox3.Items.AddStrings(temp);
temp.free;
combobox3.Text:=combobox3.Items[0];
end;
temp := TStringList.Create;
.
.
.
finally
temp.free;
end;
var
sql:string;
begin
sql:='select * from '+combobox2.Text;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(sql);
adoquery1.ExecSQL;//觉得用adoquery1.open比较好,下的active就不用了
adoquery1.Active:=true;
temp := TStringList.create;
try
temp.clear;
adoquery1.Fields.GetFieldNames(temp);
combobox3.Clear;
combobox3.Items.AddStrings(temp);
finally
temp.free;
end;
combobox3.Text:=combobox3.Items[0];
end;