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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:32:04+00:00 2026-05-30T06:32:04+00:00

I have a C#/WPF application with a tabbed interface that has been behaving strangely.

  • 0

I have a C#/WPF application with a tabbed interface that has been behaving strangely. After thinking originally my problems were related to the TabControl, I now believe that it’s something different and I’m completely stuck. The following method is just supposed to pull some data out of the database and load a couple of WPF ComboBoxes. The strange thing is that the code reaches a certain point, specifically the end of the loop that loads cboState’s Item collection, and then continues on. No code placed below that loop executes, no errors are thrown than I can find or see, and no breakpoints placed below that loop ever get reached. I’m completely perplexed.

private void loadNewProjectTab() {
    dpDate.SelectedDate = DateTime.Now;

    cboProjectType.Items.Add("Proposal");
    cboProjectType.Items.Add("Pilot");
    cboProjectType.SelectedIndex = -1;

    string sql = "SELECT State FROM States ORDER BY ID";
    OleDbCommand cmd = new OleDbCommand(sql, connection);
    if(connection.State == ConnectionState.Closed) {
        connection.Open();
    }

    OleDbDataReader reader = cmd.ExecuteReader();
    while(reader.HasRows) {
        reader.Read();
        cboState.Items.Add(reader["State"].ToString().Trim());
    } // <-- Nothing below here executes.

    connection.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-30T06:32:06+00:00Added an answer on May 30, 2026 at 6:32 am
    while(reader.HasRows) { 
        reader.Read(); 
        cboState.Items.Add(reader["State"].ToString().Trim()); 
    }
    

    reader.HasRows will return true even after you’ve read all the rows and moved past the last one with reader.Read(); at that point, you’ll get an exception on reader["State"].

    Since reader.Read() returns a boolean to indicate whether there’s a current row, you should skip calling reader.HasRows entirely:

    while(reader.Read()) { 
        cboState.Items.Add(reader["State"].ToString().Trim()); 
    }     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a WPF Application that has a two flavors with a consistent UI
I have WPF application. After testing my app on Windows7 and realized that opening
I have WPF application that has a login form. I would like to make
I have a WPF application that has just one button. When the button is
I have a wpf application that has some shapes on a canvas I want
I have a WPF application that has several modal window used for various purposes.
I have a WPF application that runs fine under XP as an administrator. When
I have a WPF application (.NET 3.0, VS2008) that displays data in a tab
I have a wpf application (C#) that needs to copy a file to a
We have a WPF Application that runs from both desktop and as a XBAP

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.