Link to home
Start Free TrialLog in
Avatar of SubbuUSA
SubbuUSAFlag for United States of America

asked on

Null handling in C#

Friends,

I have a problem. My stored procedure produces an integer values which I am assigning to an Nullable integer variable.

Dataclass where I call my Stored proc
------------
//Typecasting error happens here . Unable to cast from object to integer datatype
userProfile.NS_ID = Convert.ToInt32(dr.ItemArray[41]);

userprofile class
------------

public int? NMLS_ID
            {
                  get;
                  set;
            }

NS_ID is should get an integer..based on which I do my own business logic. but it is expected that 99% of time ..my stored proc would be producing a null because my db is fresh and users have not started using it.

How do i handle this.

REgards
Subbu
ASKER CERTIFIED SOLUTION
Avatar of petr_hlucin
petr_hlucin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SubbuUSA

ASKER

Thanks Guys