Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Handling Null Value In DataSet
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01432130
Message ID:
01432136
Views:
46
>I'm doing this:
>
>
>_RoleKey = (int)dsDataSet.Tables[0].Rows[0]["RoleKey"];
>
>
>It's throwing an exception because RoleKey is null in the data. How do I handle this?

You can branch the logic into two paths by checking for DBNull.Value first.

Also you may want to define your _RoleKey as int?
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform