2024年5月11日发(作者:圣安地列斯手机版)
FieldByName和ParamByName的区别
fieldbyname:
在数据集部件所拥有的方法中,有一个FieldByName方法,它是专门用于访问数据集部件中动态
生成的字段部件的,调用FieldByName方法时,必须要把数据库表中的字段名作为参数传给
FieldByName,调用该方法后便可以得到该字段所对应的字段部件,这样通过字段部件我们便可以读写
表中相应的字段值了,用这种方法访问字段部件时,必须要知道数据库表中各个字段的名字,否则是没
有办法调
用该方法的。
parambyname:
ParamByName是一个函数,用动态SQL语句中的参数作为调用ParamByName函数的参数,这
样便可以为它们赋值,使用这种赋值方法,必须要知道动态SQL语句参
数的名字
FieldByName是TDataSet类中public 下的一个函数,声明如下:
function FieldByName(const FieldName: string): TField;
功能是根据fieldname参数从连接的数据库中取得字段数据
ParamByName是TParameters类中的一个public
函数,声明如下:
function ParamByName(const Value: WideString): TParameter;
实现如下:
function yName(const Value: WideString): TParameter;
function GetComponent: TComponent;
begin
Result := GetCommand;
if Assigned(Result) and ( is TCustomADODataSet) then
Result := ;
end;
begin
Result := FindParam(Value);
if Result = nil then
DatabaseErrorFmt(SParameterNotFound, [Value], GetComponent);
end;
一般是用ParamByName来接收一个sql操作语句中的参数。
发布者:admin,转转请注明出处:http://www.yc00.com/xitong/1715388542a2610560.html
评论列表(0条)