Board index » delphi » ADO Insert causes Invalid Variant Type Conversion error

ADO Insert causes Invalid Variant Type Conversion error

I have a simple master-detail tables structure with ADO: ORDER and
ITEMS.
I can browse through the data without a problem, but when I issue the
command "ORDER.Insert", I get the error message: "Invalid Variant Type
Conversion".

What am I doing wrong here??? The detail table (ITEMS) have the
following properties:

MasterSource: ORDER
MasterField: ID
IndexFieldName: ITEM_ID

I read about Variant Type to NULL conversion problems, and maybe it's
got something to do with primary and foreign keys being null on
insert, but how can I make it work???

TIA for your urgent replies!!!

Jessica

 

Re:ADO Insert causes Invalid Variant Type Conversion error


A Variant is a special data type that can contain any kind of data except
fixed-length String data.

This is from the MS Access help.  I'm just a beginner who happened
to be browsing newsgroups.  Maybe this has something to do with it.
HTH
jim

Re:ADO Insert causes Invalid Variant Type Conversion error


Quote
jlori...@hotpop.com (Jessica Loriena) wrote in message <news:9beb2b43.0205172127.33a0ddbc@posting.google.com>...
> I have a simple master-detail tables structure with ADO: ORDER and
> ITEMS.
> I can browse through the data without a problem, but when I issue the
> command "ORDER.Insert", I get the error message: "Invalid Variant Type
> Conversion".

> I read about Variant Type to NULL conversion problems, and maybe it's
> got something to do with primary and foreign keys being null on
> insert, but how can I make it work???

I think you suggestion is correct and so you can do it work two ways:
1. using master/detail - drop master/detail relation before insert and
restore it after.
2. do not use master/detail relation at all - use queries instead

Re:ADO Insert causes Invalid Variant Type Conversion error


Thanks for your reply!

Quote
> 2. do not use master/detail relation at all - use queries instead

Can you give me an example? I'm new to Delphi and I always wondered if
using queries would be a better solution, but the way I imagine it, it
looks like a whole lot of coding. My idea is to loop through the
detail Grid, inserting each line with individual INSERT queries. But
then I would have to manually FILL the grid, control DBNavigator
manually, do almost everything manually! Is this the best way?? Maybe
you can give me a better idea on a more efficient way!

Thanks!

Jessica

Quote
gil...@mail.ru (curious) wrote in message <news:84b1a83c.0205192113.1fd4543f@posting.google.com>...
> jlori...@hotpop.com (Jessica Loriena) wrote in message <news:9beb2b43.0205172127.33a0ddbc@posting.google.com>...
> > I have a simple master-detail tables structure with ADO: ORDER and
> > ITEMS.
> > I can browse through the data without a problem, but when I issue the
> > command "ORDER.Insert", I get the error message: "Invalid Variant Type
> > Conversion".

> > I read about Variant Type to NULL conversion problems, and maybe it's
> > got something to do with primary and foreign keys being null on
> > insert, but how can I make it work???

> I think you suggestion is correct and so you can do it work two ways:
> 1. using master/detail - drop master/detail relation before insert and
> restore it after.
> 2. do not use master/detail relation at all - use queries instead

Other Threads