Board index » delphi » Invalid Variant Type Conversion ???

Invalid Variant Type Conversion ???

Hi,

just another help request.

I have a table with a field CF of string type ( C(16) as checked with
Database Desktop) and somewhere in the code I try something like

var s: string;
      t: TTable;
......

   s := t ['CF'];

and I get a "Invalid Variant Type Conversion" error at run-time.

        What does it means ???

        Thanks a lot, bye Luca.

 

Re:Invalid Variant Type Conversion ???


Quote
> I have a table with a field CF of string type ( C(16) as checked with
> Database Desktop) and somewhere in the code I try something like

> var s: string;
>       t: TTable;
> .......

>    s := t ['CF'];

> and I get a "Invalid Variant Type Conversion" error at run-time.

   Try   s:= t['CF'].AsString;

Volker

Re:Invalid Variant Type Conversion ???


Quote
Luca Manini wrote:

> Hi,

> just another help request.

> I have a table with a field CF of string type ( C(16) as checked with
> Database Desktop) and somewhere in the code I try something like

> var s: string;
>       t: TTable;
> ......

>    s := t ['CF'];

> and I get a "Invalid Variant Type Conversion" error at run-time.

>         What does it means ???

>         Thanks a lot, bye Luca.

Is the column null? If so then check for null first before
assigning it to the string.  I have a function Default:

function Default(x, y: Variant): Variant;
begin
  if x = Null then begin
     Result := y;
  end else begin
     Result := x;
  end;
end;

Other Threads