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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:21:14+00:00 2026-05-21T18:21:14+00:00

I have a problem in listview.I my listview i have five columns(question_number,question_text,start_time,end_time,status). the first

  • 0

I have a problem in listview.I my listview i have five columns(question_number,question_text,start_time,end_time,status). the first four columns will be fetch the data from the database.once the data has entered i have to compare the starttime and with the current time.once the starttime is greater than current time then i have to update the status column as expired. otherwise i have to say not expired.

I have attached the code what i did so for.
I do no how to get the status updated in the status column.Please any one help me.thanks in advance.

     public void GetData()
       {
        try
        {
            myConnection = new SqlConnection(@"User ID=sa;Password=password123;Initial Catalog=dish;Persist Security Info=True;Data Source=ENMEDIA-CCDDFE5\ENMEDIA");
            //myConnection.Open();
            //SqlDataReader dr = new SqlCommand("SELECT question_text,question_id FROM otvtbl_question ", myConnection).ExecuteReader();

           // listView1.Columns.Clear();
            listView1.Items.Clear();

            myConnection.Open();
            String MyString1 = string.Format("SELECT question_id,question_text,start_time,end_time FROM otvtbl_question");

            SqlCommand cmd = myConnection.CreateCommand();
            cmd.CommandText = MyString1;

            dr = cmd.ExecuteReader();

            //Adding The Column Name From The DataBase 
            for (int i = 0; i < dr.FieldCount; i++)
            {
                ColumnHeader ch = new ColumnHeader();
                ch.Text = dr.GetName(i);
                //listView1.Columns.Add(ch);
            }


            ListViewItem itmX;
            //Adding the Items To The Each Column
            while (dr.Read())
            {
                itmX = new ListViewItem();
                itmX.Text = dr.GetValue(0).ToString();

                for (int i = 1; i < dr.FieldCount; i++)
                {
                    itmX.SubItems.Add(dr.GetValue(i).ToString());
                }
                listView1.Items.Add(itmX);
            }

            dr.Close();
            myConnection.Close();
          }
           catch (Exception ex)
        {
            //Error Message While Fetching
            MessageBox.Show("Error While Fetching the data From the DataBase" + ex);
        }

        finally
        {
            //Closing The Connection
            if (dr != null)
                dr.Close();

            if (myConnection.State == ConnectionState.Open)
                myConnection.Close();

        }
  • 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-21T18:21:15+00:00Added an answer on May 21, 2026 at 6:21 pm

    Something like this?

                while (dr.Read())
                {
                    ...
                    listView1.Items.Add(itmX);
    
                    if (dr.GetDateTime(2) > dr.GetDateTime(3))
                    {
                        itmX.SubItems.Add("Expired");
                    }
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem with a Listview. I can load it with listview
I have problem when I try insert some data to Informix TEXT column via
I have a problem on refresh the listview using thread. How to use it
calling ListView's setSelection() seems to have a problem. a lot of people ask about
I have a problem. Currently i'm using Lazyloading to load images and data into
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for

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.