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

  • SEARCH
  • Home
  • 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 7809289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:23:17+00:00 2026-06-02T03:23:17+00:00

I read my database using DataReader. and some row does not have fdate value.

  • 0

I read my database using DataReader.

and some row does not have fdate value.

so when I Convert the null date to DateTime then Error occurs.

How can I check the field empty or not?

AdsCommand cmd = conn.CreateCommand();
cmd.CommandText = "select name,fdate from abc";

AdsDataReader reader = cmd.ExecuteReader();

DateTime flsdate = (reader["fdate"].Equals(null))? Convert.ToDateTime(reader["fdate"]) : DateTime.Today;

I tried with Equals, but it does not work.

anybody know how to check the null object to avoid convert error?

Thank you!

  • 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-02T03:23:20+00:00Added an answer on June 2, 2026 at 3:23 am

    As everyone pointed you how to solve the issue, I am trying to give you the info regarding what is the difference between NULL and DBNull.

    • null and DBNull are different.

    • null is not an instance of any type. DBNull is a singleton class with one instance: DBNull.Value.

    • null represents an invalid reference where as DBNull.Value represents a nonexistent value in DB.

    • DBNull.Value is what db providers provide for a nonexistant value in a table.

    With that background (reader["fdate"].Equals(null)) is not correct to use here. You have to check it with DBNull.Value. If it is of type DBNull, or if it is equal to DBNull.Value, then assign what ever value you like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read that using database keys in a URL is a bad thing
I am using JNDI to read database configuration from my application's context.xml. The way
I'm trying to read data from SQL Server database using Perl and the DBI
I'm using Linq to SQL and read in a blog post about closing database
I'm using PHP to read if an entry in my table on the database
How to upgrade read only sqlite database I have tried to change to SQLiteDatabase.OPEN_READWRITE);
I have a SQL Server database and I'm using ADO.NET ExecuteReader to get a
I'm creating an application that is supposed to read text from mySql database using
Database is created (and updated) using Ti.Database with titanium code. I have created an
I am using System.Data.Sqlite to access SQLite database in C#. I have a query

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.