getting error object cannot be cast from dbnull to other types.
please help me to solve this error.
in this line m getting error..m using c#.
userType = Convert.ToInt16(oCmd.Parameters["SUSER_TYPE"].Value);
here i want to check != System.DBNull.Value
what to write for this...
I do not see where you are trying to do the cast to throw that error.
And where are you assigning the value from the db?
You will have to check. If (var != DBNull.Value)
I got the solution
Originally Posted by NightStalker-DNS
userType = oCmd.Parameters["SUSER_TYPE"].Value;
by removing the convert.toint16 and taking usertype datatype as object earlier i was taking datatype as int.
ok. But for future note
Convert.ToInt16 = short
Convert.ToInt32 = int
Convert.ToIng64 = long