M
Minor
Unregistered / Unconfirmed
GUEST, unregistred user!
我在datamodule写了个funciton
function TDM.Getuserlist: Tstrings;
var tmp:Tstrings;
begin
tmp:=Tstringlist.Create;
try
with Query do
begin
close;
sql.Clear;
sql.Add('select * from user');
open;
first;
while not eof do
begin
tmp.Add(fieldbyname('UserName').AsString);
next;
end;
end;
result:=tmp;
finally
tmp.Free;
end;
end;
然后在loginform上有个combobox,要把tstings内容赋给它
procedure TFrm_login.FormShow(Sender: TObject);
begin
combobox1.Items:=Dm.Getuserlist;
end;
我尝试过会发生严重错误。请教应该如何写代码。
function TDM.Getuserlist: Tstrings;
var tmp:Tstrings;
begin
tmp:=Tstringlist.Create;
try
with Query do
begin
close;
sql.Clear;
sql.Add('select * from user');
open;
first;
while not eof do
begin
tmp.Add(fieldbyname('UserName').AsString);
next;
end;
end;
result:=tmp;
finally
tmp.Free;
end;
end;
然后在loginform上有个combobox,要把tstings内容赋给它
procedure TFrm_login.FormShow(Sender: TObject);
begin
combobox1.Items:=Dm.Getuserlist;
end;
我尝试过会发生严重错误。请教应该如何写代码。