请教(100分)

  • 主题发起人 主题发起人 gaoliang80
  • 开始时间 开始时间
G

gaoliang80

Unregistered / Unconfirmed
GUEST, unregistred user!
private
{ Private declarations }
function getfieldname:string;
function getsortway:string;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ADODataSet1AfterOpen(DataSet: TDataSet);
var
icount:integer;
begin
for icount:=0 to adodataset1.fields.count-1 do
begin
rgfieldnames.items.add(adodataset1.Fields[icount].fieldname);
end;
rgfieldnames.ItemIndex:=0;
end;

function tform1.getfieldname:string;
begin
result:=adodataset1.fields[rgfieldnames.itemindex].fieldname;
end;

function tform1.getsortway:string;
begin
result:='ASC';
if rbtndesc.checked then
result:='DESC';
end;

procedure Tform1.Button1Click(sender:tobject);
begin
adodataset1.Sort:=getfieldname+getsortway;
end;
end.
报错:项目在所需的名称或序数中未被发现
 
大哥,在排序的字段名与升降序选择之间加上一个空格。

begin
adodataset1.Sort:=getfieldname+' '+getsortway;
end;
 
对上面的兄弟说的很对,如果没加空格,系统就识别不了,
以为你的字段名加上'ASC'或'DESC'是一个字段名,而不是你想的升序和降序!!
 

Similar threads

后退
顶部