Q:

System.Data.SqlClient.SqlException: 'Invalid column name '"

I have written the below code in dataGridView celldouble click event with full row select, so whenever I double click the row it should feed back to textbox and comboxes.
But I'm getting the error "System.Data.SqlClient.SqlException: 'Invalid column name 'new1'.'"
where new 1 is the genderm in this field.
Instead of reading combobox2 's value it's reading genderm
SqlConnection conn = new SqlConnection(config.constring);
SqlCommand command = new SqlCommand("SELECT rangemaster.code as 
     code, rangemaster.genderm as [Male], rangemaster.genderf as [Female], 
     rangemaster.age as [Age], rangemaster.agerange as [Age Range], 
     rangemaster.commonrange as [Common Range], testmaster.testname as 
    [Test Name] FROM rangemaster LEFT JOIN testmaster ON rangemaster.code = 
    testmaster.code where rangemaster.code = " + 
    dataGridView1.SelectedRows[0].Cells[0].Value.ToString() + "", conn);

conn.Open();
using (SqlDataReader reader = command.ExecuteReader())
    while (reader.Read())
    {

        name4.Text = reader[0].ToString();
        textBox4.Text = reader[1].ToString();
        textBox3.Text = reader[2].ToString();
        comboBox1.SelectedIndex = Convert.ToInt32(reader[3]) - 1;
        textBox5.Text = reader[4].ToString();
        textBox1.Text = reader[5].ToString();

        comboBox2.SelectedIndex = Convert.ToInt32(reader[6]) - 1;

    }
conn.Close();

A:

The problem is that you are missing quotes. In any case the correct solution, is to use SQL parameters like:
SqlCommand command = new SqlCommand("SELECT rangemaster.code as ... where rangemaster.code = @param");
command.Parameters.Add("@param",SQlDbType.Nvarchar).Value = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

