title: Where is the error in my syntax? Getting values from SQL Server database
body: <p>I am trying to read an integer from a SQL Server database by text in comboboxes.
  I get a "Syntax error" "near" my Table name "Seeweg". The debugger does not highlight the line, where the error happens.</p>
  
  <p>The column with the value I like to get is named <code>seadistance</code>. The other columns, by which to sort are <code>start</code> and <code>ziel</code>.</p>
  
  <p>They get sorted by the values written in the comboboxes.</p>
  
  <p>To reproduce this procedure I inserted the code into a class and called the instance by a button named <code>btnSea</code>.</p>
  
  <p>I already searched for similar problems, but I could not find any syntax errors concerning the string implementation. The column names are correct.</p>
  
  <pre><code>//The Button
  private void btnSea_Click(object sender, EventArgs e)
          {
              Entnehmen CO2 = new Entnehmen();
              int Dist = CO2.Werte("Seeweg", "start", "ziel", "seadistance", comboSeaOrig.Text, comboSeaDest.Text);
              MessageBox.Show(Dist.ToString());
          }
  </code></pre>
  
  <pre><code>//The class
  class Entnehmen
  {
          public int Werte(string Tabelle, string Reihe1, string Reihe2, string Wertereihe, string WertReihe1, string WertReihe2)
          {
              int Wert = 0;
              string myConnection = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;Connect Timeout=30";
  
              using (SqlConnection myConn = new SqlConnection(myConnection))
              {
                  myConn.Open();
                  SqlCommand SelectCommand = new SqlCommand("SELECT '" + Wertereihe + "' FROM '" + Tabelle + "' WHERE '" + Reihe1 + "' = '" + WertReihe1 + "' AND '" + Reihe2 + "' = '" + WertReihe2 + "' ; ", myConn);
                  Wert = (int)SelectCommand.ExecuteScalar();
              }
              return Wert;
          }
      }
  }
  </code></pre>
  
  <p>I expect the value to be given back. Before that happens, I get the error:</p>
  
  <blockquote>
    <p>Incorrect syntex near 'Seeweg'</p>
  </blockquote>
  
  <p>Where is the syntax mistake? Any help is appreciated =)</p>