Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9298597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:21:47+00:00 2026-06-18T22:21:47+00:00

Problem Definition: I have a table in a SQL Server database. This table has

  • 0

Problem Definition:
I have a table in a SQL Server database. This table has an column of type image and it allows null values. I’m going to read this table using SqlDataReader and show the images if they are available.

What I tried first time: To check whether the image column is null or not I did this

SqlDataReader reader = command.ExecuteReader();  // command is a SqlCommand

while(reader.Read())
{
    if(reader["Image"] != null)     // Image is a column name of the table
    {
        //Do something
    }
}

The result: But it never equals to null (I also checked the Equal method). This column never is null even if has not data inserted (In SQL Server I can see it is actually null)

What I tried second time: So I tried this code and its working but I wonder why it doesn’t return null.

SqlDataReader reader = command.ExecuteReader();  // command is a SqlCommand

while(reader.Read())
{
    if(reader["Image"].GetType() != typeof(System.DBNull)) 
    {
        //Do something
    }
}

Question: Any idea to explain this behavior? I will be pleased if there is a better way to find out whether the columns of type Image in SQL Server Tables are null or not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T22:21:48+00:00Added an answer on June 18, 2026 at 10:21 pm

    You should just check for DbNull this way.

    if(reader["Image"] != DbNull.Value)     // Image is a column name of the table
    {
        //Do something
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple database table (SQL Server 2008 R2 Express), which has a
I have a positions table in SQL Server 2008R2 (definition below). In the system
I have problem with initializing data into SQL Server Compact .sdf data file in
I have a question about User-Defined Table Types in SQL Server 2008. For the
Is it possible to convert text from a table column in SQL Server to
I have a strange problem implementing pl/sql procedure. My procedure has four varchar input
I have a database table with a primary key called PremiseID. Its MySQL column
I have a problem understanding one style definition in Windows 8 metro apps. When
Problem: I have a table that prints out vertical but I would like it
I am using Nhibernate with Fluent, to persist a SQL Server 2008 express database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.