请教用一个Function得到表的逻辑(中文)字段名
假如用WWTable控件联结到一个表,该表的字段名为(field1,field2,field3)
在wwTable中将各字段的DisplayLabel设置为(编号,姓名,性别)
请教如何用一个
Function GetFieldName(物理字段名): 逻辑字段名
问题点数:20、回复次数:4Top
1 楼shcqupc(shcqupc)回复于 2005-06-02 18:51:11 得分 0
是不是我说的不太清楚? 还是分给的太少了?。。。。。Top
2 楼qq153788616(啊灌)回复于 2005-06-02 19:20:08 得分 0
顶Top
3 楼Open2ye(Open2ye)回复于 2005-06-03 00:48:52 得分 20
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, ADODB, Grids, DBGrids;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
ADOTable1: TADOTable;
BitBtn1: TBitBtn;
DBGrid1: TDBGrid;
procedure BitBtn1Click(Sender: TObject);
private
fUNCTION GETFNAME(S:STRING):STRING;
fUNCTION GETFNAME2(S:STRING):STRING;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.GETFNAME(S: STRING): STRING;
var i:integer;
begin
for i :=0 to ADOTable1.FieldCount-1 do begin
if ADOTable1.Fields[i].DisplayLabel=S then
Result:=ADOTable1.Fields[i].FieldName;
end; //For
end;
function TForm1.GETFNAME2(S: STRING): STRING;
begin
Result:=ADOTable1.Fieldbyname(s).DisplayName;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
with ADOTable1 do begin
Fields[0].DisplayLabel:='A';
Fields[1].displayLabel:='B';
Fields[2].DisplayLabel:='C';
ShowMessage(GETFNAME('A'));
ShowMessage(GETFNAME2('field1'));
end; //with
end;
end.
Top
4 楼shcqupc(shcqupc)回复于 2005-06-03 12:47:41 得分 0
非常感谢!!Top




