你好,请问如何在DELPHI中,取出数据表的最后一条记录的某个字段值,并 赋值给变量?谢谢!
1个回答
2016-04-27
展开全部
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB, DBTables;
type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
x:real;
begin
table1.Last;
x:=table1.fieldbyname('weight').AsFloat;
//edit1.Text:=inttostr(trunc(x));
edit1.Text:=floattostr(x);
end;
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询