Introduce DataBase,Asp.net,JavaScript,Xml,Html,Css,Sql,Php,ASP.NET Controls,AJAX,Tools,HTML,CSS,JavaScript,Open Source Project,WPF,.Net Framework,Linq
Top Recommended Hosting

Visual C# Express Check Data column if null C#

by the3factory 4/10/2008 1:58:00 AM
Visual C# Express Check Data column if null C#
Question:
Hi ! (C#)
  I have created a table in the sql with the column "parent_id" int set to allow null. I wana check to see if the parent_id value is a null value but whenever i do this :

foreach (WebDataSet.CategoryRow MyRows in webDataSet.Category.Rows)
            {
                if (MyRows.parent_id == null )
                {
                }
            }

It gives me an error "StrongTypingExeption Error was Unhandled"
"The value for column 'parent_id' in table 'Category' is DBNull."

well thats the Idea !!! i wana check to see if its null but the checking itself is already giving me troubles. also it gives me this note "the result of BLAHBLAH is always true since a value of BLAHBLAH is always null" ok so how do I check to see if parent_id is null so that i will not execute any line of codes inside that IF . thanks



The Answer is not in the BOX ! It lies beneath the Head

Answer1:

Do it this way:

 

if (MyRows.IsNull("parent_id"))

Answer2:

You might also try:

 

System.DBNull.Value == MyRows.parent_id

Answer3:

 

yeah

 

thanks for that.

Related posts

Sign up for PayPal and start accepting credit card payments instantly.


Powered by BlogEngine.NET 1.2.0.0