title: How to prevent from automatically adding whitespace character in SQL Server?
body: <p>I have a problem about SQL Server in my visual studio 2012 web site project. For example; I have a table named "user" that has columns "name" ( varchar(16) ) and "surname" ( varchar(16) ). I add new data such as name: "john" surname: "holiday", but SQL Server automatically fills the rest of the variable with whitespace character. It seems like <img src="https://i.stack.imgur.com/Zh65c.jpg" alt="">. How can I block this? I hope I explained my problem clearly. </p>
  
  <pre><code>protected void LoginButton_Click(object sender, EventArgs e)
  {
      string connectionString = "Data Source=MYPC-PC\\SQLEXPRESS;Initial Catalog=fff;Integrated Security=True";
      SqlConnection connection = new SqlConnection(connectionString);
      try
      {
          connection.Open();
      }
      catch (Exception s)
      {
          FailureText.Text = s.ToString();
      }
      SqlCommand cmd = new SqlCommand("SELECT * FROM [person] WHERE user_name='" + UserName.Text + "' AND user_password='" + Password.Text + "' ", connection);
  
      SqlDataReader dr = null;
      dr = cmd.ExecuteReader();
  
      while (dr.Read())
      {
          if (this.CompareStrings(dr["user_name"].ToString(), UserName.Text) &amp;&amp;
              this.CompareStrings(dr["user_password"].ToString(), Password.Text))
          {
              FailureText.Text = "ok";
          }
          else
          {
              FailureText.Text = "no";
          }
  
  
      }
      connection.Close();
      dr.Close();
  }
  </code></pre>
  
  <p>For example when I am debugging "dr["user_name"]" variable is like that in watch : <img src="https://i.stack.imgur.com/e5LUy.jpg" alt=""> </p>