title: How can I retrieve a table from stored procedure to a datatable?
body: <p>I created a stored procedure so as to return me a table.</p>
  
  <p>Something like this:</p>
  
  <pre><code>create procedure sp_returnTable
  body of procedure
  select * from table
  end
  </code></pre>
  
  <p>When I call this stored procedure on the frontend what code do I need to write to retrieve it in a datatable object?</p>
  
  <p>I wrote code something like the following. I basically want to know retrieving and storing table into an object of datatable. All my queries are running, but I don't know how to retrieve table into a datatable through a stored procedure</p>
  
  <pre><code>DataTable dtable = new DataTable();
  cmd.Connection = _CONN;
  
  cmd.CommandText = SPNameOrQuery;
  cmd.CommandType = CommandType.StoredProcedure;
  
  SqlDataAdapter adp = new SqlDataAdapter(cmd);
  OpenConnection();
  adp.Fill(dtTable);
  CloseConnection();
  </code></pre>
  
  <p>Here in this code a command has been bound with the stored procedure name and its parameters. Will it be returning me a datatable from the stored procedure?</p>