C
Claudia Fong
Hi,
I have a comboBox and a textbox in my form. I already can display in a
comboBox the department names; what I would like to do is display in a
textbox the department ID related to the department name I chose from
comboBox.
below is the extract of the code:
OleDbCommand myCommand3 = new OleDbCommand();
myCommand3.Parameters["DEPT_NAME"].Value = comboBox2.SelectedItem; --->
THIS LINE GENERATE THE ERROR System.IndexOutOfRangeException
objConnection.Open();
OleDbDataReader objReader3 = myCommand3.ExecuteReader();
objReader3.Read();
textBox4.Text = Convert.ToString(objReader3["DEPT_CODE"]);
objReader3.Close();
objConnection.Close();
I have a comboBox and a textbox in my form. I already can display in a
comboBox the department names; what I would like to do is display in a
textbox the department ID related to the department name I chose from
comboBox.
below is the extract of the code:
OleDbCommand myCommand3 = new OleDbCommand();
myCommand3.Parameters["DEPT_NAME"].Value = comboBox2.SelectedItem; --->
THIS LINE GENERATE THE ERROR System.IndexOutOfRangeException
objConnection.Open();
OleDbDataReader objReader3 = myCommand3.ExecuteReader();
objReader3.Read();
textBox4.Text = Convert.ToString(objReader3["DEPT_CODE"]);
objReader3.Close();
objConnection.Close();