Board index » delphi » OLE Automation, "Invalid Variant Conversion"

OLE Automation, "Invalid Variant Conversion"

Hope someone can help me with this problem. I am using OLE Automation to
control an Access Database. I am trying to get data from an Access Table.
The Field in question is empty. When it tries to execute the statement, I
get an "Invalid Variant Conversion". I am using Delphi 2.01, with Access 7.

Code:
procedure Convert;
begin
        ...
        // Assume all OLE objects have been created.
        // Database is the currently open access database

         RecordSet := Database.OpenRecordSet('select * from OFFICE');

        Fax2 := RecordSet.Fields['Fax'].Value; <== Invalid Variant                                                    
Conversion
end;

If I put data in the field, doesn't complain at all. I can assign values to
the Field using:
        RecordSet.Fields['Fax'].Value := Fax2;  // Fax2 has been initialized.

I have tried typcasting, checking to see if it is equal to '', ' ', and
NULL.. None seem to work.

Any insights or help would greatly be appreciated.

thanks
Bryce
p.s. Please cc a reply to vbfisc...@tasc.com

 

Re:OLE Automation, "Invalid Variant Conversion"


Re:OLE Automation, "Invalid Variant Conversion"


Never mind! I must not have checked for NULL. I was trying to prove it to a
co-worker, and it worked when I tested for NULL

Re:OLE Automation, "Invalid Variant Conversion"


Re:OLE Automation, "Invalid Variant Conversion"


On 15 May 1997 20:05:37 GMT, "Bryce Fischer" <*fisch...@ix.netcom.com>
wrote:

Quote
>Hope someone can help me with this problem. I am using OLE Automation to
>control an Access Database. I am trying to get data from an Access Table.
>The Field in question is empty. When it tries to execute the statement, I
>get an "Invalid Variant Conversion". I am using Delphi 2.01, with Access 7.

>Code:
>procedure Convert;
>begin
>    ...
>    // Assume all OLE objects have been created.
>    // Database is the currently open access database

>     RecordSet := Database.OpenRecordSet('select * from OFFICE');

>            Fax2 := RecordSet.Fields['Fax'].Value; <== Invalid Variant                                                    
>Conversion
>end;

>If I put data in the field, doesn't complain at all. I can assign values to
>the Field using:
>    RecordSet.Fields['Fax'].Value := Fax2;  // Fax2 has been initialized.

>I have tried typcasting, checking to see if it is equal to '', ' ', and
>NULL.. None seem to work.

You might try testing for UnAssigned, which is supposed to be
different from Null

Good luck

Marcel Mar
Amsterdam, The Netherlands

e-mail: *remove_this*mjm...@inter.nl.net*remove_this*

Re:OLE Automation, "Invalid Variant Conversion"


Actually, I believe all you have to use is the
VarAsType(<variable>,varOleString) or whatever you need to do...

Bruce

Quote
Marcel J Mar wrote:

> On 15 May 1997 20:05:37 GMT, "Bryce Fischer" <*fisch...@ix.netcom.com>
> wrote:

> >Hope someone can help me with this problem. I am using OLE Automation to
> >control an Access Database. I am trying to get data from an Access Table.
> >The Field in question is empty. When it tries to execute the statement, I
> >get an "Invalid Variant Conversion". I am using Delphi 2.01, with Access 7.

> >Code:
> >procedure Convert;
> >begin
> >       ...
> >       // Assume all OLE objects have been created.
> >       // Database is the currently open access database

> >        RecordSet := Database.OpenRecordSet('select * from OFFICE');

> >               Fax2 := RecordSet.Fields['Fax'].Value; <== Invalid Variant
> >Conversion
> >end;

> >If I put data in the field, doesn't complain at all. I can assign values to
> >the Field using:
> >       RecordSet.Fields['Fax'].Value := Fax2;  // Fax2 has been initialized.

> >I have tried typcasting, checking to see if it is equal to '', ' ', and
> >NULL.. None seem to work.

> You might try testing for UnAssigned, which is supposed to be
> different from Null

> Good luck

> Marcel Mar
> Amsterdam, The Netherlands

> e-mail: *remove_this*mjm...@inter.nl.net*remove_this*

Other Threads