InvalidArgument=Value of '0' is not valid for 'index'. Parameter name: index
void loadSubject(ComboBox cbo) { try { SqlConnection con = new SqlConnection(cs.getConnectionString()); con.Open(); DataTable dt = new DataTable(); string query = "SELECT subjectcode,description FROM tblsubject WHERE description LIKE '%' + @1 + '%' ORDER BY description ASC"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@1",cbosubject.Text); SqlDataReader dr = cmd.ExecuteReader(); dt.Load(dr); cbo.DisplayMember = "description"; cbo.ValueMember = "subjectcode"; cbo.DataSource = dt; } catch (Exception) { publicFunctions.mBox(3, "error occured"); } }
private void cbosubject_TextChanged(object sender, EventArgs e) { loadSubject(cbosubject); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)