cannot convert parameter 2 from 'int' to 'int'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary

    #1

    cannot convert parameter 2 from 'int' to 'int'

    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",S ystem::Type::Ge tType(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::D ataRow::set_Ite m(int,System::O bject __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?




  • Tomas Restrepo \(MVP\)

    #2
    Re: cannot convert parameter 2 from 'int' to 'int'

    Gary,
    [color=blue]
    >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",S ystem::Type::Ge tType(S"System. Int32"));[/color]

    A simpler way is:
    Books->Columns->Add("Volume" , __typeof(int));

    [color=blue]
    > Then below I try to add an int value to it.
    >
    > Nr->Item[S"Volume"] = Volume;[/color]

    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);


    --
    Tomas Restrepo
    tomasr@mvps.org



    Comment

    Working...