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 / C# / March 2008

Tip: Looking for answers? Try searching our database.

Error message from error provider when I don't select an item

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vanessa - 06 Mar 2008 19:44 GMT
Hi all!

I am creating a class to databing to a form. My difficulty is with combobox.
I have a field that is related to the customer table, where the customer ID
is an integer and I show its name in the combobox. In the class I have a
property of the type int to catch the ID. Everything works fine if I select
an item in the combobox, however if I don't select an item, the error
provider shows the following message:

"Object of type 'System.DBNull' cannot be converted to type 'System.Int32'"

Does someone has an idea how can I do to no have this message?

sds,
Vanessa
Ben Voigt [C++ MVP] - 06 Mar 2008 22:26 GMT
> Hi all!
>
[quoted text clipped - 10 lines]
>
> Does someone has an idea how can I do to no have this message?

You could change the property to int?  (That is Nullable<int>, not a
question)

> sds,
> Vanessa
Vanessa - 07 Mar 2008 11:49 GMT
Hi Ben!

Thank you very much! It worked like I wanted.

Vanessa

> > Hi all!
> >
[quoted text clipped - 16 lines]
> > sds,
> > Vanessa
Ben Voigt [C++ MVP] - 07 Mar 2008 14:14 GMT
> Hi Ben!
>
> Thank you very much! It worked like I wanted.

You're welcome.

> Vanessa
>
[quoted text clipped - 18 lines]
>>> sds,
>>> Vanessa

Rate this thread:







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.