Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
UserID UniqueIdentifier filed

us.UserID = (Guid)reader["UserID"]; how i can check
null value plz help me

Posted
Comments
Bernhard Hiller 26-Mar-14 3:14am    
Where can that null value be - in your class, in the database, both?
Do you think it makes sense to use a UniqueIdentifier which can be null - what's the purpose of such an idea?
satheeshkumar chinnadurai 26-Mar-14 3:20am    
Not UserID - CompanyID some where i am using null values some where assign value

1 solution

Guid is a struct in .NET - which means it's a value type, and that can't hold null values.
If you have null Guids in your database - which is probably a poor idea - then you need to check the returned value against DBNull.Value when you pull it from the reader, and (probably) assign Guid.Empty to your UserID instead.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900