title: C# Get results from SQL query in a text box
body: <p>I have the following code (no errors) which should get the result of the SQL query and put it in the <code>HolEmpName</code> text box, but it remains blank.</p>
  
  <pre><code>public void holidayempname()    
  {
      string query = "SELECT 'Employee Name' FROM dbo.Employees WHERE EmployeeID = @HolidayEmployeeID;";
  
      using (SqlConnection cn = new SqlConnection())
      using (SqlCommand cmd = new SqlCommand(query, cn))
      {
          cmd.Parameters.Add("@HolidayEmployeeID", SqlDbType.UniqueIdentifier).Value = holiday_EmployeeIDTextBox.Text;
          cn.Open();
          object result = cmd.ExecuteScalar();
          cn.Close();
          if (result != null)
          {
              int value = (int)result;
              HolEmpName.Text = value.ToString();
          }
      }
  }
  </code></pre>
  
  <p>Table Structure:</p>
  
  <p>Employees:</p>
  
  <pre><code>EmployeeID
  Employee Name
  </code></pre>
  
  <p>Holidays:</p>
  
  <pre><code>HolidayID
  Holiday EmployeeID
  </code></pre>
  
  <p>Current Code:</p>
  
  <pre><code>    public void holidayempname()
  
      {
          string query = "SELECT [Employee Name] FROM dbo.Employees WHERE EmployeeID = @HolidayEmployeeID;";
  
          using (SqlConnection cn = new SqlConnection())
          using (SqlCommand cmd = new SqlCommand(query, cn))
          {
              cmd.Parameters.Add("@HolidayEmployeeID", holiday_EmployeeIDComboBox.Text);
              //cmd.Parameters.Add("@HolidayEmployeeID", SqlDbType.UniqueIdentifier).Value = holiday_EmployeeIDComboBox.Text;
              cn.Open();
              object result = cmd.ExecuteReader();
              cn.Close();
              if (result != null)
              {
                  int value = (int)result;
                  HolEmpName.Text = value.ToString();
              }
          }
      }
  </code></pre>