I keep getting this error whenever I do the search: Invalid column name 'datafromcombobox'
I tried hardcode the data in my SQL query and it works. Any idea what's wrong with my code?
Here's the code:
        string selectedMedication = cboMedicationType.SelectedItem.ToString();
        string strMedications = "SELECT medicationName FROM MEDICATION WHERE medicationType= (" + selectedMedication + ")";
        SqlCommand cmdMedications = new SqlCommand(strMedications, connection);
        connection.Open();
        SqlDataReader readMedications = cmdMedications.ExecuteReader();
        while (readMedications.Read())
        {
            string medicationVar = readMedications["medicationName"].ToString();
            clbMedication.Items.Add(medicationVar, true);
        }
        readMedications.Close();
        connection.Close();
 
     
     
    