Delphi怎么读取access表中某一格的数据放到Label的Caption里面
Delphi如何读取access表中某一格的数据放到Label的Caption里面?
Delphi如何读取access表中某一格的数据放到Label的Caption里面?
------解决思路----------------------
putInLable(1,1,Label1);
就是把ADOTable1表中的第一行第一列的内容放到Label1中。


你也可以把putInLable这个过程写得简单些:
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
Label1: TLabel;
.....................
.....................
private
{ Private declarations }
public
{ Public declarations }
procedure putInLable(recN,recM:integer;theLable:TLabel);
//-------参数说明:第recN行,第recM列,theLable是程序中的Lable名。
end;
......................
procedure TForm1.putInLable(recN,recM:integer;theLable:TLabel);
begin
with ADOTable1 do
begin
first;
MoveBy(recN-1);
theLable.Caption:=ADOTable1.Fields[recM-1].AsString;
end;
end;
-----------------------------------------
另外,再见朋友们,不玩了,发贴的验证码,太让人抓狂!!!!!!实在是受不了!!!再也不来了!!!
------解决思路----------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Grids, DBGridEh, DB, ADODB;
type
TForm1 = class(TForm)
con1: TADOConnection;
qry1: TADOQuery;
DBGridEh1: TDBGridEh;
lbl1: TLabel;
btn1: TButton;
ds1: TDataSource;
procedure btn1Click(Sender: TObject);
private
procedure putInLable(recN,recM:integer);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.putInLable(recN,recM:integer);
begin
with qry1 do
begin
Close;
sql.Clear;
sql.Add('select * from gamelist'); //gamelist 填写成你自己的表
open;
first;
MoveBy(recN-1);
lbl1.Caption:=Fields[recM-1].AsString;
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
putInLable(3,3);
end;
end.
Delphi如何读取access表中某一格的数据放到Label的Caption里面?
------解决思路----------------------
putInLable(1,1,Label1);
就是把ADOTable1表中的第一行第一列的内容放到Label1中。
你也可以把putInLable这个过程写得简单些:
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
Label1: TLabel;
.....................
.....................
private
{ Private declarations }
public
{ Public declarations }
procedure putInLable(recN,recM:integer;theLable:TLabel);
//-------参数说明:第recN行,第recM列,theLable是程序中的Lable名。
end;
......................
procedure TForm1.putInLable(recN,recM:integer;theLable:TLabel);
begin
with ADOTable1 do
begin
first;
MoveBy(recN-1);
theLable.Caption:=ADOTable1.Fields[recM-1].AsString;
end;
end;
-----------------------------------------
另外,再见朋友们,不玩了,发贴的验证码,太让人抓狂!!!!!!实在是受不了!!!再也不来了!!!
------解决思路----------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Grids, DBGridEh, DB, ADODB;
type
TForm1 = class(TForm)
con1: TADOConnection;
qry1: TADOQuery;
DBGridEh1: TDBGridEh;
lbl1: TLabel;
btn1: TButton;
ds1: TDataSource;
procedure btn1Click(Sender: TObject);
private
procedure putInLable(recN,recM:integer);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.putInLable(recN,recM:integer);
begin
with qry1 do
begin
Close;
sql.Clear;
sql.Add('select * from gamelist'); //gamelist 填写成你自己的表
open;
first;
MoveBy(recN-1);
lbl1.Caption:=Fields[recM-1].AsString;
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
putInLable(3,3);
end;
end.