title: Cannot call methods on nvarchar
body: <p>I have strange problem with simple SELECT statement, which I use in my asp.net application. I work with MSSQL 2008. </p>
  
  <p>This statement works:</p>
  
  <pre><code>SelectSQL = "SELECT user_id, user_name, user_surname, user_code FROM Users WHERE user_group = '" + drop.SelectedItem.Value + "'";
  </code></pre>
  
  <p>however, this line throws "<em>Cannot call methods on nvarchar.</em>"</p>
  
  <pre><code>SelectSQL = "SELECT COUNT(DISTINCT Equations.eq_id) AS pocet_prikladu, Users.user_name, User.user_surname FROM Users LEFT JOIN Equations ON (Users.user_id = Equations.eq_user_id) WHERE Users.user_code = '" + drop.SelectedItem.Value + "' GROUP BY Users.user_id, Users.user_name, User.user_surname ";
  </code></pre>
  
  <p>here is more code, it stops at the last line</p>
  
  <pre><code>public void FillTable(Table tab, DropDownList drop)     //naplneni tabulky
      {
          SqlConnection pripojeni = new SqlConnection(connectionString);
          string SelectSQL = "";
          if (action == "groups")
          {
              SelectSQL = "SELECT user_id, user_name, user_surname, user_code FROM Users WHERE user_group = '" + drop.SelectedItem.Value + "'";
          }
          else
          {
              SelectSQL = "SELECT COUNT(DISTINCT Equations.eq_id) AS pocet_prikladu, Users.user_name, User.user_surname FROM Users LEFT JOIN Equations ON (Users.user_id = Equations.eq_user_id) WHERE Users.user_code = '" + drop.SelectedItem.Value + "' GROUP BY Users.user_id, Users.user_name, User.user_surname ";
          }
          try
          {
              SqlCommand prikaz = new SqlCommand(SelectSQL, pripojeni);
              pripojeni.Open();
              SqlDataReader vysledky = prikaz.ExecuteReader();
  </code></pre>