프로그래밍/C#

mysql 콤보박스로 오픈하지 않고 나오게 하기

뽀로로친구에디 2019. 1. 23. 11:27

string query = "select * from customer_tab";

MySqlCommand cmd;


cmd = new MySqlCommand(query, conn);


MySqlDataAdapter da = new MySqlDataAdapter(cmd);

DataTable table = new DataTable("myTable");

da.Fill(table);


foreach (DataRow row in table.Rows)

{

     for (int i = 0; i < row.ItemArray.Length; i++)

     {

          comboBox1.Items.Add(row.ItemArray[1].ToString());


     }

}






   MySqlConnection myConn = new MySqlConnection("datasource = '" + this.textBox_host_ip.Text + "';port=3306;username=root;password=password");

            string selectstring = "select * from wdata_mdb.factory where layout_name = '"+this.cb_layout.Text+"';";

            MySqlDataAdapter myadp = new MySqlDataAdapter(selectstring, myConn);

            DataTable table = new DataTable("robot");


            myadp.Fill(table);


            foreach (DataRow row in table.Rows)

            {

                this.cb_robot_id.Items.Add(row.ItemArray[4].ToString());

            }