F
fei_l
Unregistered / Unconfirmed
GUEST, unregistred user!
自己建立的对象,最好自己释放,这是一个好习惯。
而且最好将接收对象以参数的形式传进来操作
procedure TUserMaint.GetDepList(listbox: Tlistbox);
var
i: Integer;
tmpstrs: TStrings;
begin
tmpstrs:=TStringlist.Create;
with UserDM do
try
if not adcUser.Connected then
adcUser.Connected:=True;
adqTemp.sql.Clear;
adqTemp.sql.add('select * from M_BMBM');
adqTemp.Open;
for i:=1 to adqTemp.RecordCount do
begin
tmpstrs.Add(adqTemp.Fieldbyname('BMMC').AsString);
adqTemp.Next;
end;
adqTemp.Close;
listbox.items:=tmpstrs;
tmpstrs.free;
finally
adcUser.Connected:=False;
end;
end;
而且最好将接收对象以参数的形式传进来操作
procedure TUserMaint.GetDepList(listbox: Tlistbox);
var
i: Integer;
tmpstrs: TStrings;
begin
tmpstrs:=TStringlist.Create;
with UserDM do
try
if not adcUser.Connected then
adcUser.Connected:=True;
adqTemp.sql.Clear;
adqTemp.sql.add('select * from M_BMBM');
adqTemp.Open;
for i:=1 to adqTemp.RecordCount do
begin
tmpstrs.Add(adqTemp.Fieldbyname('BMMC').AsString);
adqTemp.Next;
end;
adqTemp.Close;
listbox.items:=tmpstrs;
tmpstrs.free;
finally
adcUser.Connected:=False;
end;
end;