Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary - 16 Jul 2005 20:03 GMT
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?
Tomas Restrepo (MVP) - 16 Jul 2005 21:36 GMT
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/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.