private DataViewManager dsview;
 private DataTable dtgen;


MySqlConnection myconn = new MySqlConnection("server=localhost;database=octupus_db;userid=root;password=sys");
 MySqlDataAdapter sqlgender = new MySqlDataAdapter("Select * from gender", myconn);
                 
                       
            MySqlCommandBuilder comgen = new MySqlCommandBuilder(sqlgender);

            sqlgender.TableMappings.Add("gendermapping","gender");

                      

            DataTable  dtgen = new DataTable("gender");
            sqlgender.Fill(dtgen);


            cbxgender.Items.Add(dtgen.Rows()"sex".ToString);

My problem looks simple, but i cannot crack it. I have connected to my DB, extracted the data populated it to a Data table. But somehow i can't link this data table with my combo box but its failing.

my table is called gender, and the field that i am interested is called sex

Any ideas are welcome.

br Justus

DataSource Bindings.

MySqlConnection myconn = new MySqlConnection("server=localhost;database=octupus_db;userid=root;password=sys");
  MySqlDataAdapter sqlgender = new MySqlDataAdapter("Select * from gender", myconn);
                 
  DataTable  dtgen = new DataTable("gender");
  sqlgender.Fill(dtgen);


   cbxgender.DataSource=dtgen;
   cbxgender.ValueMember=dtgen.Columns[0].ColumnName;
   cbxgender.DisplayMember=dtgen.Columns[1].ColumnName;

Welcome to the forums justech, Please take some time to introduce your self at http://www.daniweb.com/forums/forum165.html.

Why don't you just Hard code it, or are there more than two genders?
Why make an extra unnecessary connection, it is not good practice.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.