The value of my ComboBox
is from the sql database and its working great but I want to get the Med_id
of the value inorder for me to add another entry
Med_ID
is a foreign key from another table, is there a way to get it and add it to y ledger table?
here's the code:
string MyConnection2 = "datasource=localhost;port=3306;user id=root;password=''";
string Query = "INSERT INTO
newssph.ledger(Date, Reference, Rec_Qty, Iss_Qty, Bal_Qty, Med_ID)
VALUES('" + txtdate.Text + "','" + comboBox4.Text + "','"
+ this.txtrec.Text + "','" + this.txtissue.Text +
"','" + this.txtbal.Text + "','" + id + "','" +
"');";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataReader MyReader2;
MyConn2.Open();
MyReader2 = MyCommand2.ExecuteReader();
MessageBox.Show("Data Added");