Discussion:
invalid class typecast
(too old to reply)
yc
2005-04-25 10:25:31 UTC
Permalink
Hi,

I'am trying to use TLargeIntField, it is giving me a headache.

I've two Access tables tbl1 and tbl2 (qry1 and qry2).
Using TLargeIntField field type as follows, I get an invalid class typecast exception.

var
li : TLargeIntField;
begin
with qry1 do
begin
Close;
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
Parameters.ParamByName('REFNO').Value := li.Value;
Open;
end;
end;

Any idea ?

Thanks in advance
yc
Andrew Ryazanov
2005-04-25 10:59:20 UTC
Permalink
Post by yc
I'am trying to use TLargeIntField, it is giving me a headache.
I've two Access tables tbl1 and tbl2 (qry1 and qry2).
Using TLargeIntField field type as follows, I get an invalid class typecast exception.
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
Why do you cast it as TLargeInt? This means the INT64 type while MS Access
doesn't support INT64 fields. Suppose you need just TIntegerField.
Mike Shkolnik
2005-04-25 11:06:40 UTC
Permalink
Post by Andrew Ryazanov
Why do you cast it as TLargeInt? This means the INT64 type while MS Access
doesn't support INT64 fields.
MS Access database supports the INT64 fields. There is the dbBigInt field
type and this is same to ftLargeint in VCL

--
With best regards, Mike Shkolnik
EMail: ***@scalabium.com
http://www.scalabium.com
Barak zabari
2005-04-25 12:14:04 UTC
Permalink
Parameters.ParamByName('REFNO').Value := li.Value;

Useing D6 + ADO i run into lots of problems regarding the Value and
LargeInt, if you will check the assignment you will probably see that the
Value passed is wrong when the Value is larger then normal Int.
In my case i gave up on BigInt and just use Float.
Post by Mike Shkolnik
Post by Andrew Ryazanov
Why do you cast it as TLargeInt? This means the INT64 type while MS Access
doesn't support INT64 fields.
MS Access database supports the INT64 fields. There is the dbBigInt field
type and this is same to ftLargeint in VCL
--
With best regards, Mike Shkolnik
http://www.scalabium.com
yc
2005-04-25 12:01:25 UTC
Permalink
That's right to use Float is a soln. but not enough.
Because, int64 has a precision of 18 digit (may be closer)
on the other hand Float has less.
Seems like to me, the only soln. is not to use int64 only use
float instead
Post by yc
Parameters.ParamByName('REFNO').Value := li.Value;
Useing D6 + ADO i run into lots of problems regarding the Value and
LargeInt, if you will check the assignment you will probably see that the
Value passed is wrong when the Value is larger then normal Int.
In my case i gave up on BigInt and just use Float.
Post by Mike Shkolnik
Post by Andrew Ryazanov
Why do you cast it as TLargeInt? This means the INT64 type while MS
Access
Post by Mike Shkolnik
Post by Andrew Ryazanov
doesn't support INT64 fields.
MS Access database supports the INT64 fields. There is the dbBigInt field
type and this is same to ftLargeint in VCL
--
With best regards, Mike Shkolnik
http://www.scalabium.com
Mike Shkolnik
2005-04-25 11:08:36 UTC
Permalink
Are you sure that your 'REFNO' detected as TLargeIntField in Delphi?

Anyway try the next instead:
Parameters.ParamByName('REFNO').Value := qry2.FieldByName('REFNO').Value;

--
With best regards, Mike Shkolnik
EMail: ***@scalabium.com
http://www.scalabium.com
Post by yc
Hi,
I'am trying to use TLargeIntField, it is giving me a headache.
I've two Access tables tbl1 and tbl2 (qry1 and qry2).
Using TLargeIntField field type as follows, I get an invalid class typecast exception.
var
li : TLargeIntField;
begin
with qry1 do
begin
Close;
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
Parameters.ParamByName('REFNO').Value := li.Value;
Open;
end;
end;
Any idea ?
Thanks in advance
yc
Viatcheslav V. Vassiliev
2005-04-25 11:30:21 UTC
Permalink
Post by yc
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
var
str: string;

str := qry.FieldByname('REFNO').ClassName;

You will see what is this field.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
Post by yc
Hi,
I'am trying to use TLargeIntField, it is giving me a headache.
I've two Access tables tbl1 and tbl2 (qry1 and qry2).
Using TLargeIntField field type as follows, I get an invalid class typecast exception.
var
li : TLargeIntField;
begin
with qry1 do
begin
Close;
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
Parameters.ParamByName('REFNO').Value := li.Value;
Open;
end;
end;
Any idea ?
Thanks in advance
yc
yc
2005-04-25 12:03:07 UTC
Permalink
Post by Viatcheslav V. Vassiliev
Post by yc
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
var
str: string;
str := qry.FieldByname('REFNO').ClassName;
You will see what is this field.
ok, lets say the field name is TIntegerField, is there any way to use int64 instead of integer ?
Post by Viatcheslav V. Vassiliev
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
Post by yc
Hi,
I'am trying to use TLargeIntField, it is giving me a headache.
I've two Access tables tbl1 and tbl2 (qry1 and qry2).
Using TLargeIntField field type as follows, I get an invalid class typecast exception.
var
li : TLargeIntField;
begin
with qry1 do
begin
Close;
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
Parameters.ParamByName('REFNO').Value := li.Value;
Open;
end;
end;
Any idea ?
Thanks in advance
yc
John Herbster
2005-04-25 15:20:19 UTC
Permalink
...
YC,
Is there any reply in your reply?
If so I did not see it.
Regards, JohnH
Viatcheslav V. Vassiliev
2005-04-25 15:45:01 UTC
Permalink
Do you use persistent fields or auto-generated?

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
Post by yc
Post by Viatcheslav V. Vassiliev
Post by yc
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
var
str: string;
str := qry.FieldByname('REFNO').ClassName;
You will see what is this field.
ok, lets say the field name is TIntegerField, is there any way to use
int64 instead of integer ?
Post by Viatcheslav V. Vassiliev
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
Post by yc
Hi,
I'am trying to use TLargeIntField, it is giving me a headache.
I've two Access tables tbl1 and tbl2 (qry1 and qry2).
Using TLargeIntField field type as follows, I get an invalid class typecast exception.
var
li : TLargeIntField;
begin
with qry1 do
begin
Close;
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
Parameters.ParamByName('REFNO').Value := li.Value;
Open;
end;
end;
Any idea ?
Thanks in advance
yc
yc
2005-04-26 05:58:50 UTC
Permalink
I tried both persistent fields and auto-generated
Post by Viatcheslav V. Vassiliev
Do you use persistent fields or auto-generated?
yc
2005-04-25 14:32:32 UTC
Permalink
Hi again,
I just figured out something I wonder if it is ok ?
It didn't raise any exception.

var
nf : TNumericField;
i64 : Int64;
begin
with qry1 do
begin
Close;
nf := qry2.FieldByName('REFNO') as TNumericField;
i64 := nf.Value;
Parameters.ParamByName('REFNO').Value := i64;
Open;
end;
end;

Thanks again
yc
Post by yc
Hi,
I'am trying to use TLargeIntField, it is giving me a headache.
I've two Access tables tbl1 and tbl2 (qry1 and qry2).
Using TLargeIntField field type as follows, I get an invalid class typecast exception.
var
li : TLargeIntField;
begin
with qry1 do
begin
Close;
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
Parameters.ParamByName('REFNO').Value := li.Value;
Open;
end;
end;
Any idea ?
Thanks in advance
yc
Barak zabari
2005-04-28 09:06:09 UTC
Permalink
My guess is that by useing TNumericField you will get the precision of a
numeric field and that's not what you wanted.
Try to put an 18 digit number in the database and run this if you get the
currect value back to the database then you should be good.
Post by yc
Hi again,
I just figured out something I wonder if it is ok ?
It didn't raise any exception.
var
nf : TNumericField;
i64 : Int64;
begin
with qry1 do
begin
Close;
nf := qry2.FieldByName('REFNO') as TNumericField;
i64 := nf.Value;
Parameters.ParamByName('REFNO').Value := i64;
Open;
end;
end;
Thanks again
yc
Post by yc
Hi,
I'am trying to use TLargeIntField, it is giving me a headache.
I've two Access tables tbl1 and tbl2 (qry1 and qry2).
Using TLargeIntField field type as follows, I get an invalid class typecast exception.
var
li : TLargeIntField;
begin
with qry1 do
begin
Close;
li := qry2.FieldByName('REFNO') as TLargeIntField; //EXCEPTIO is here
Parameters.ParamByName('REFNO').Value := li.Value;
Open;
end;
end;
Any idea ?
Thanks in advance
yc
Continue reading on narkive:
Loading...