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 6656357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:38:00+00:00 2026-05-26T01:38:00+00:00

Howsit! I encounter an error when i get a null value in my datareader.

  • 0

Howsit!

I encounter an error when i get a null value in my datareader.

public List<Complaint> View_all_complaints()
{
    csDAL objdal= new csDAL();
    List<Complaint> oblcomplist=new List<Complaint>();

    using( IDataReader dr=objdal.executespreturndr("View_all_complaints"))
    {
        while (dr.Read())
        {
            Complaint objcomp= new Complaint();
            populate_reader(dr,objcomp);
            oblcomplist.Add(objcomp);
        }
    }
    return oblcomplist;
}

public void populate_reader(IDataReader dr, Complaint objcomp)
{
    objcomp.ref_num = dr.GetString(0);
    objcomp.type = dr.GetString(1);
    objcomp.desc = dr.GetString(2);
    objcomp.date = dr.GetDateTime(3);
    objcomp.housenum = dr.GetInt32(4);
    objcomp.streetnum = dr.GetInt32(5);
    objcomp.status = dr.GetString(6);
    objcomp.priority = dr.GetString(7);
    objcomp.cid = dr.GetInt32(8);
    if (!dr.IsDBNull(9))
    {
        objcomp.resolved_date = dr.GetDateTime(9);
    }
}

in sql resolved date allows null values, this is so because only when a complaint has been resolved , it must reflect that date otherwise it should be null.

if dr.getdatetime(9) is null then it must just set a string saying “Not Resolved”

please help!

  • 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-05-26T01:38:00+00:00Added an answer on May 26, 2026 at 1:38 am

    You haven’t shown what your Complaint type looks like, but basically you’ll want to make sure that its resolved_date is of type DateTime? aka Nullable<DateTime>. That allows you to model a missing value elegantly.

    As for displaying it – you haven’t shown anything about where you display the data, but you’d want something like:

    string text = complaint.ResolvedDate.HasValue ? complaint.ResolvedDate.ToString()
                                                  : "Not Resolved";
    

    (I’ve changed this to use a property with the idiomatic name at the same time…)

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

Sidebar

Related Questions

if(up.xhr.sendAsBinary != null) { //firefox up.xhr.open('POST', '/html5_upload.php?up=true', true); var boundary = 'xxxxxxxxx'; var body
I currently have a preg_match to detect http:// and www. etc..... but I want
howzit! I'm a web developer that has been recently requested to develop a Windows
Here is the site: http://wesbos.com/tf/shutterflow/?cat=1 The banner image at the side that says S&S
Hey, hows it going everyone? I am having database conflicts I was wanting some
I want to use pg_escape_string in my password can anyone sugest me hows it
I have this object parsed using SimpleXML: SimpleXMLElement Object ( [contact] => SimpleXMLElement Object
I am using Twilio API to receive SMS text messages. I want to store
Howzit guys! I have to compare multiple rows of data with each other and
I have group of checkboxes nearly equals to 100 all are with name checkbox1...checkbox1oo.

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.