I have a ComboBox (dropdown) that I populate from a Database field containing 3 fields.
Prob_id char(4) indexed by 1
Description_id varchar(25)
Status varchar(6)
I need to be able to write the Prob_id to a different table upon selecting a Description_id. Right now my code passes both the Prob_id and the Description_id to the app and I can write them both to two separate CB boxes ( I did this to make sure the data was being sent).
However I dont think this is the right way to do this... I cant figure out how to pass the correct Prob_id that corresponds with the Description_id back to the new table. My instinct tells me I need to be doing this on Server side with a stored procedure that I cant figure out either or I some type of statement that keeps them together on the app side so I could then just pass the Prob_id into the new table.
Please help I just cant wrap my mind around this
Thanks
This is the code where it is read in.
BR>private void load_cb()
{
myconnection.Open();
SqlCommand get_open = new SqlCommand("mp_statusopen", myconnection);
get_open.CommandType = CommandType.StoredProcedure;
//select from Problem_table * where status='open' ordered by prob_id
//{alNames.Add(drAuthors.GetValue(0));
SqlDataReader dr_open = get_open.ExecuteReader();
string st_open = null;
string x = null;//added to handle the prob_id
while (dr_open.Read())
{
x = dr_open.GetValue(0).ToString();
st_open = dr_open.GetValue(1).ToString();
//GetValue(insert column number starts with 0)
Desc_cb.Items.Add(st_open);
Prob_cb.Items.Add(x);//added to handle the prob_id
}
myconnection.Close();
}
This is the button for adding the data back to the DB
private void Submit_btn_Click(object sender, EventArgs e)
{
myconnection.Open();
SqlCommand Submit_btn = new SqlCommand("mp_submitbtn", myconnection);
Submit_btn.CommandType = CommandType.StoredProcedure;
Submit_btn.Parameters.AddWithValue("@Description", Desc_cb.Text);
//Submit_btn.Parameters.AddWithValue("@Prob_id", Prob_cb.Text);
Submit_btn.Parameters.AddWithValue("@Call",Call_box.Text);
Submit_btn.Parameters.AddWithValue("@date", DateTime.Now.ToString());
Submit_btn.ExecuteNonQuery();
myconnection.Close();
}
;