I have managed to read data into a datatable (see below) and can passthe displaymember variable (description_id) back but I can not pass the othervariable in the table (prob_id) which is not displayed back to the server.
please look at my code below. I know missing something I just can figure it out. I am assuming that it is in the subm_btn method but I can not get the code right to pass the prob_id back.
ThanksMark
Table Exampleprob_id Description_id-------- ---------------1 oom2 bad eggs3 pirate kind
private void load_cb() { myconnection.Open(); SqlCommand cmd = new SqlCommand("mp_statusopen", myconnection); cmd.CommandType = CommandType.StoredProcedure; DataTable dt_probdesc = new DataTable(); SqlDataAdapter adaptor = new SqlDataAdapter(cmd); adaptor.Fill(dt_probdesc); Desc_cb.DataSource = dt_probdesc; Desc_cb.DisplayMember = "Description_id"; //"desc" is whatever the column in the server name is that you want displayed. myconnection.Close(); } private void Form1_Load(object sender, EventArgs e) { load_cb(); } 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", Desc_cb.SelectedValue); Submit_btn.Parameters.AddWithValue("@Call",Call_box.Text); Submit_btn.Parameters.AddWithValue("@date", DateTime.Now.ToString()); Submit_btn.ExecuteNonQuery(); myconnection.Close(); }
private void load_cb() { myconnection.Open();
SqlCommand cmd = new SqlCommand("mp_statusopen", myconnection); cmd.CommandType = CommandType.StoredProcedure; DataTable dt_probdesc = new DataTable(); SqlDataAdapter adaptor = new SqlDataAdapter(cmd);
adaptor.Fill(dt_probdesc);
Desc_cb.DataSource = dt_probdesc; Desc_cb.DisplayMember = "Description_id"; //"desc" is whatever the column in the server name is that you want displayed. myconnection.Close();
} private void Form1_Load(object sender, EventArgs e) { load_cb(); }
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", Desc_cb.SelectedValue); Submit_btn.Parameters.AddWithValue("@Call",Call_box.Text); Submit_btn.Parameters.AddWithValue("@date", DateTime.Now.ToString());
Submit_btn.ExecuteNonQuery(); myconnection.Close(); }