过程声明 procedure b_com(com:TComboBox;a:string;b:string);
过程实现 procedure Tfrm_xygdjb.b_com(com:TComboBox;a:string;b:string);
begin
com.Clear;
with data1.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select distinct '+a+' from '+b);
open;
end;
while Not data1.ADOQuery1.Eof do
begin
com.Items.Add(data1.ADOQuery1.FieldByName('a'));
Data1.ADOQuery1.Next;
end;
end;过程调用 frm_xygdjb.b_com(ComboBox3;'工种';'工种表'); 各位帮我看看好不好 谢谢了
过程实现 procedure Tfrm_xygdjb.b_com(com:TComboBox;a:string;b:string);
begin
com.Clear;
with data1.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select distinct '+a+' from '+b);
open;
end;
while Not data1.ADOQuery1.Eof do
begin
com.Items.Add(data1.ADOQuery1.FieldByName('a'));
Data1.ADOQuery1.Next;
end;
end;过程调用 frm_xygdjb.b_com(ComboBox3;'工种';'工种表'); 各位帮我看看好不好 谢谢了
过程实现 procedure Tfrm_xygdjb.b_com(com:TComboBox;a:string;b:string);
begin
com.Clear;
with data1.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select distinct '+a+' from '+b);
open;
end;
while Not data1.ADOQuery1.Eof do
begin
com.Items.Add(data1.ADOQuery1.FieldByName('a'));
Data1.ADOQuery1.Next;
end;
end;
过程调用 frm_xygdjb.b_com(ComboBox3;'工种';'工种表'); //错误提示处
各位帮我看看好不好 谢谢了
好象是参数取值问题提示: 1. Not enough actual parameter
2. Satament expected but expression of the Type 'String' Found
showmessage(sql.text);
应该是
com.Items.Add(data1.ADOQuery1.FieldByName(a));
改成
com.Items.Add(data1.ADOQuery1.FieldByName(a).AsString);
改成
com.Items.Add(data1.ADOQuery1.FieldByName(a).AsString);
还是不行啊 麻烦大家再帮我看看好不
frm_xygdjb.b_com(ComboBox3;'工种';'工种表');
调用的时候是逗号","不是分号";". 第二个错误肯定是写的时候什么地方漏了分号";". 还有,你的Query都没有执行. ADOQuery1.Open;