gpt4 book ai didi

mysql - 如何获取TADOQuery中字段的长度?

转载 作者:行者123 更新时间:2023-11-29 08:32:46 25 4
gpt4 key购买 nike

比如我可以获取某个字段的值。但是是否可以查出该字段的长度呢?

MyQuery.Fields[0].Value; // contains the value of the field

最佳答案

字段大小可以从 Field.Size 获取,如果此值为 0 Size,则它是您使用 Field.Datasize 的固定类型。

简短示例:

uses TypInfo;

Procedure DisplayFieldInfos(DS:TDataset;List:TStrings);
var
i:Integer;
Function GetSize(F:Tfield):Integer;
begin
Result := F.Size;
if Result=0 then Result := F.DataSize;
end;
begin
for I := 0 to DS.FieldCount - 1 do
begin // display Fieldname [Datatype] : Size
List.Add(Format('%s [%s] : %d',
[
DS.Fields[i].FieldName,
GetEnumName(TypeInfo(TFieldType), integer(DS.Fields[i].Datatype)),
GetSize(DS.Fields[i])
]));
end;
end;

procedure TForm6.Button1Click(Sender: TObject);
begin
DisplayFieldInfos(ADS,Memo1.Lines)
end;

关于mysql - 如何获取TADOQuery中字段的长度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16094766/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com