D
djdsz
Unregistered / Unconfirmed
GUEST, unregistred user!
我在一个MIDAS应用中,因为必须将TParams转换成XML格式,所以用了如下的方法:
function TRzCommObj.ParamsToString(InParams: TParams): string;
var
i:integer;
begin
with TClientDataSet.Create(nil)do
try
with FieldDefs.AddFieldDefdo
begin
Name:='Name';
DataType:=ftString;
size:=50;
end;
with FieldDefs.AddFieldDefdo
begin
Name:='Value';
DataType:=ftstring;//本来在这我要用ftVariant,可是错误
size:=500;
end;
with FieldDefs.AddFieldDefdo
begin
Name:='Type';
DataType:=ftinteger;
end;
with FieldDefs.AddFieldDefdo
begin
Name:='ParamType';
DataType:=ftinteger;
end;
createDataSet;//将上面注释地方改用ftVariant在这发生运行错误
for i:=0 to InParams.Count-1do
InsertRecord([InParams.Items.Name,InParams.Items.Value,ord(InParams.Items.DataType),ord(InParams.Items.ParamType)]);
result:=xmldata;
finally
free;
end;
end;
请问,TVariantField该怎么用?上面代码的问题在哪?
function TRzCommObj.ParamsToString(InParams: TParams): string;
var
i:integer;
begin
with TClientDataSet.Create(nil)do
try
with FieldDefs.AddFieldDefdo
begin
Name:='Name';
DataType:=ftString;
size:=50;
end;
with FieldDefs.AddFieldDefdo
begin
Name:='Value';
DataType:=ftstring;//本来在这我要用ftVariant,可是错误
size:=500;
end;
with FieldDefs.AddFieldDefdo
begin
Name:='Type';
DataType:=ftinteger;
end;
with FieldDefs.AddFieldDefdo
begin
Name:='ParamType';
DataType:=ftinteger;
end;
createDataSet;//将上面注释地方改用ftVariant在这发生运行错误
for i:=0 to InParams.Count-1do
InsertRecord([InParams.Items.Name,InParams.Items.Value,ord(InParams.Items.DataType),ord(InParams.Items.ParamType)]);
result:=xmldata;
finally
free;
end;
end;
请问,TVariantField该怎么用?上面代码的问题在哪?