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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:42:04+00:00 2026-06-04T08:42:04+00:00

I am filling a ComboBox via a SQL Data Adapter and I have run

  • 0

I am filling a ComboBox via a SQL Data Adapter and I have run into an issue where the adapter is bringing back a count of four tables. This is odd because there are only three tables within the database, and it is filling the final table (ds.Tables[3]) instead of the initial table (ds.Tables[0]) with the appropriate rows.

The following code does NOT populate the ComboBox (Take note of cboCities.DataSource (the second to last line)):

         private void Form1_Load(object sender, EventArgs e)
    {
        // Establishes a connection to the database.
        SqlCeConnection cn = new SqlCeConnection(@"Data Source = C:\Users\user\Desktop\Projects\ParkSurvey WF\ParkSurvey WF\ParkSurvey.sdf; Persist Security Info = False; Password = *");
        cn.Open();
        // Gathering the names of cities from the Cities database to populate cboCities.
        SqlCeCommand cmd = cn.CreateCommand();
        cmd.CommandText = "SELECT CityId, Name FROM Cities ORDER BY Name ASC";
        SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        // Closing the connection and setting the data bindings for cboCities.
        cn.Close();
        cboCities.ValueMember = "CityId";
        cboCities.DisplayMember = "Name";
        cboCities.DataSource = ds.Tables[0];
        cboCities.SelectedIndex = -1;
    }

This DOES populate the ComboBox appropriately (take note again of cboCities.DataSource):

        private void Form1_Load(object sender, EventArgs e)
    {
        // Establishes a connection to the database.
        SqlCeConnection cn = new SqlCeConnection(@"Data Source = C:\Users\user\Desktop\Projects\ParkSurvey WF\ParkSurvey WF\ParkSurvey.sdf; Persist Security Info = False; Password = *");
        cn.Open();
        // Gathering the names of cities from the Cities database to populate cboCities.
        SqlCeCommand cmd = cn.CreateCommand();
        cmd.CommandText = "SELECT CityId, Name FROM Cities ORDER BY Name ASC";
        SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        // Closing the connection and setting the data bindings for cboCities.
        cn.Close();
        cboCities.ValueMember = "CityId";
        cboCities.DisplayMember = "Name";
        cboCities.DataSource = ds.Tables[3];
        cboCities.SelectedIndex = -1;
    }

What is causing my DataAdapter to bring back four tables instead of JUST Cities, and why is it populating the fourth table instead of the initial table? Please let me know if you require more code sample to help assist me with this issue. Thank you very much!

  • 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-04T08:42:06+00:00Added an answer on June 4, 2026 at 8:42 am

    It should work if you fill a DataTable instead of a DataSet since you’re selecting only one table anyway.

    Apart from that, i must admit that don’t know the reason for this behaviour.

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

Sidebar

Related Questions

I have a 2 Table. Product ProductName CategoryID Category ID CategoryName I'm filling combobox
I'am filling tables in .net DataSet with data. There is a nested relation between
I'm filling an XML document manually using C# and I need to have <data>
I have my combobox is filling from dgv on form load everything is ok,
I'm filling PDF applications using classes that represent the pdf. I have a property
I have problems filling a temporary table with the resultset from a procedure call
I am filling a GridView with the data table but on each row I
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
I have problem with filling a Map in Java, I think this is simple,
I have a TableAdapter filling a DataSet , and for some reason every select

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.