title: Select Parameter Anomaly
body: <p>This is driving me crazy, and even though it doesn't really matter right now I'd like to know what's going on.</p>
  
  <p>I have a Stored Procedure called ClientSelect:</p>
  
  <pre><code>SELECT * FROM dbo.Client
  </code></pre>
  
  <p>That's all that's in it (I've stripped it right back to try and figure out what's going on!)</p>
  
  <p>I also have an ASP.NET page with a GridView.  Its DataSource looks like this:</p>
  
  <pre><code>&lt;asp:SqlDataSource ID="SQLClient" runat="server"
          ConnectionString="&lt;%$ ConnectionStrings:TestDBConnectionString %&gt;" 
          SelectCommand="EXEC ClientSelect" &gt;
          &lt;SelectParameters&gt;
              &lt;asp:Parameter Name="ClientID" Type="Int32"  /&gt;
          &lt;/SelectParameters&gt;
  &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>Note that the SelectCommand does not make any reference to the SelectParameter, and the Stored Procedure does not ask for any parameters.  This page loads, but the GridView is empty - no data returned.</p>
  
  <p>However, if I remove the SelectParameter completely, or add a default value so that it looks like:</p>
  
  <pre><code>&lt;asp:Parameter Name="ClientID" Type="Int32" DefaultValue="1"  /&gt;
  </code></pre>
  
  <p>It returns all the records in the table (not filtering by the specified default value).</p>
  
  <p>Why is the explicit coding of a SelectParameter causing no data to be returned, even though neither my SelectCommand or my Stored Procedure are making any reference to it at all?  It doesn't make sense to me!</p>