//只要前五条记录
procedure TForm1.Button1Click(Sender: TObject);
begin
  with ADODataSet1 do begin
    Close;
    CommandText := 'SELECT TOP 5 * FROM country';
    Open;
  end;
end;

//去除重复
procedure TForm1.Button2Click(Sender: TObject);
begin
  with ADODataSet1 do begin
    Close;
    CommandText := 'SELECT DISTINCTROW * FROM country';
    Open;
  end;
end;

//获取字段列表
procedure TForm1.Button3Click(Sender: TObject);
var
  i: Integer;
  str: string;
begin
  str := '';
  for i := 0 to ADODataSet1.FieldDefs.Count - 1 do
  begin
    str := str + ADODataSet1.FieldDefs[i].Name + sLineBreak;
  end;
  ShowMessage(str);
end;

posted on 2009-05-28 18:42  万一  阅读(3380)  评论(9编辑  收藏  举报