Problem with Large Integer
Posted: Thu 05 May 2005 20:31
I'm having a problem copying the data (value) from one record to another only when the field type of ftLargeint. If the field is of this type, the value is not assigned. Below is a snipet of code; query1 does a select * from a table and query2 does the same from the same table. When I loop through the fields from query1 and assign the values from there to a new record in query2 all values are properly assigned to the new record except those that are largeint. I have commented out the code that will work around the issue, but I was wonder why I have to do it this way (if the datatype is smallint it works fine also).
procedure TForm1.BitBtn2Click(Sender: TObject);
var
i: integer;
begin
with myquery2 do
begin
close;
Open;
insert;
for i := 1 to myquery1.FieldCount - 1 do
begin
// if fields.DataType in [ftLargeint] then
// fields.asinteger := myquery1.fields.asinteger
// else
fields.Value := myquery1.fields.Value;
end;
post;
end;
myquery1.Refresh;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
i: integer;
begin
with myquery2 do
begin
close;
Open;
insert;
for i := 1 to myquery1.FieldCount - 1 do
begin
// if fields.DataType in [ftLargeint] then
// fields.asinteger := myquery1.fields.asinteger
// else
fields.Value := myquery1.fields.Value;
end;
post;
end;
myquery1.Refresh;
end;