title: .net: How to execute a stored procedure with a nullable parameter in c#?
body: <p>How to execute a stored procedure with a nullable parameter in c#?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>Actually, I've written below code. As you can see, status parameter is a nullable value type. 
  Is it correct? or not?</p>
  
  <pre><code>public void LoadAll(DataTable tb, int? status=null)
      {
          try
          {
              using (SqlConnection connection = new SqlConnection())
              {
                  connection.ConnectionString = this.connectionString;
  
                  using (SqlCommand command = connection.CreateCommand())
                  {
                      command.CommandType = CommandType.StoredProcedure;
                      command.CommandText = "USP_OrganizationChartSelect";
                      SqlCommandBuilder.DeriveParameters(command);
                      command.Parameters["@Status"].Value = status.HasValue ? status : null;
                      if (connection.State != ConnectionState.Open)
                          connection.Open();
                      SqlDataAdapter adapter = new SqlDataAdapter(command);
                      tb.Clear();
                      adapter.Fill(tb);
                      adapter.Dispose();
                      adapter = null;
                  }
              }
          }
          catch (Exception ex)
          {
              throw ex;
          }
      }
  </code></pre>
  
  <p>Thanks</p>