0
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

3
Contributors
2
Replies
6
Views
6 Years
Discussion Span
Last Post by finito
0

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;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.