I have a strange compile error. C2664 cannot convert parameter 2 from int to
int...
Earlier in my code I was setting up my dataset...
I add an int field like so...
Books->Columns->Add("Volume",System::Type::GetType(S"System.Int32"));
Then below I try to add an int value to it.
Nr->Item[S"Volume"] = Volume;
(Nr is a new Datarow of the table "books"
And get this error:
error C2664: 'void System::Data::DataRow::set_Item(int,System::Object __gc
*)' : cannot convert parameter 2 from 'int' to 'int'
I checked to see if it was because the column and the variable have the same
name but setting it to the value 1 also caused the same error.
What am I doing wrong?
Gary,
>I have a strange compile error. C2664 cannot convert parameter 2 from int
>to int...
[quoted text clipped - 4 lines]
>
> Books->Columns->Add("Volume",System::Type::GetType(S"System.Int32"));
A simpler way is:
Books->Columns->Add("Volume", __typeof(int));
> Then below I try to add an int value to it.
>
> Nr->Item[S"Volume"] = Volume;
The problem here is that the compiler gets confused because of overloads of
the Item property. A simple way to get what you want is to simply box the
volume:
Nr->Item[S"Volume"] = __box(Volume);

Signature
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/