I'm trying to run a query in MySQL database with C#. I want the column prioritySettings returned when the 3 previous columns are within certain values. This query works, but only with one variable at a time, so at the moment I can only specify the value of one of the columns. Are my AND statements correct?
string query = "SELECT prioritySetting FROM {DATABASE} WHERE handling ='" + handling + "'" + "AND corner ='" + corner + "'" + "AND power  ='" + power + "'";
some more code;
                 MySqlDataReader sqlReader;                                       
                string handling = overOrUnderInput;
                string corner = cornerPartInput;
                string power = onOrOffPowerInput;
                string query = "SELECT prioritySetting FROM {DATABASE} WHERE handling ='" +             handling + "'" + " AND corner ='" + corner + "'" + " AND power  ='" + power + "'"; 
                MySqlCommand getRecords = new MySqlCommand(query, connection);
                connection.Open();
                sqlReader = getRecords.ExecuteReader();
                    while (sqlReader.Read())
                    {
                        try
                        {
                            try
                            {
                                suggestions[i] = (sqlReader.GetString(0));
                            }
                            catch
                            {
                            }
                            i++;
                        }
                        catch (MySqlException ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
and the error;
System.NullReferenceException: Object reference was not set to an instance of an object.
 
     
     
     
    