title: How to read stored procedure output and return it as list
body: <p>I have table which has composite keys in order to retrieve data from two different tables. I have created stored procedures to do that and it works fine:</p>
  
  <p>Stored procedure:</p>
  
  <pre><code>ALTER PROC dbo.spp_adm_user_user_group_sel
  AS 
  BEGIN 
      SET NOCOUNT ON
  
      SELECT 
          g.name AS Group_Name, u.fullname, u.designation, 
          u.email, u.mobile 
      FROM 
          TBL_ADM_USER_GROUP g, TBL_ADM_USER u
      WHERE 
          g.id = u.group_id 
          AND (g.deleted IS NULL OR g.deleted &lt;&gt; 1)
  END
  </code></pre>
  
  <p>The result is like this:</p>
  
  <pre><code>Group_name  fullname    designation  email          mobile
  Alex        fffffffff   Engineer     sss@mail.come  3333333333
  Jon        hhhhhhhhh    programmer   hh@mail.com    020202028347
  </code></pre>
  
  <p>As you can see, the stored procedure does not have any parameters. How to read this output and return it as list using C#?</p>
  
  <p>Code: </p>
  
  <pre><code>public List&lt;string&gt; GetData()
  {
      using (SqlConnection con = new SqlConnection(Global.Config.ConnStr))
      {
          string group;
  
          DataTable dt = new DataTable();
          List&lt;string&gt; details = new List&lt;string&gt;();
  
          SqlCommand cmd = new SqlCommand("spp_adm_user_user_group_sel", con);
          cmd.CommandType = CommandType.StoredProcedure;
  
          SqlDataAdapter da = new SqlDataAdapter(cmd);
          da.Fill(dt);
  
          foreach (DataRow dr in dt.Rows)
          {
              details.Add(group);
          }
      }
  
      return details;
  }
  </code></pre>