title: How to return a DataSet to a View
body: <p>I am sending a standard Sql select statement to my Sql box via the SqlDataAdapter, then populating a DataSet object.</p>
  
  <p>I can access the rows in the resulting DataSet, but how can I convert the DataSet into a List which can be returned to the MVC View. i.e. I'm assuming a List object is the best way to handle this.</p>
  
  <p>Here's my controller c# code:</p>
  
  <pre><code>public class QAController : Controller
  {
  
      private readonly static string connString = ConfigurationManager.ConnectionStrings["RegrDBConnection"].ToString();
      private readonly static SqlConnection sqlConn = new SqlConnection(connString);
      private readonly static SqlCommand sqlComm = new SqlCommand();
  
      public ActionResult Index()
      {
          DbRegressionExec();
          return View();
      }
      public static void DbRegressionExec()
      {
          // SELECT TABLE CONTENTS FROM SQL !!
          RegressDB_TableList regresDB = new RegressDB_TableList();
          string sqlStr = "select * from [RegressionResults].[dbo].[Diff_MasterList] order by TableName";
  
          // POPULATE DATASET OBJECT
          DataSet ds = new DataSet();
          SqlDataAdapter da = new SqlDataAdapter(sqlStr, sqlConn);
          da.SelectCommand.CommandType = CommandType.Text;
          sqlConn.Open();
          try
          {
              da.Fill(ds, "RegresDB");
          }
          catch (Exception e)
          {
              throw;
          }
          finally
          {
              sqlConn.Close();
          }
  
         // I can iterate thru rows here, but HOW DO CONVERT TO A LIST OBJECT ????
  
          int numRows = ds.Tables["RegresDB"].Rows.Count;
          for (int i = 0; i &lt; numRows; i++)
          {
              string tblName = ds.Tables["RegresDB"].Rows[i].Field&lt;string&gt;("TableName");
          }
  
          //List&lt;RegressDB_TableList&gt; masterList = regresDB.RegresTableList.ToList(); //not working !!
          //var masterList = regresDB.TableName.ToList(); //
  
      }
  
  }
  </code></pre>
  
  <p>and a simple class I may need to make this happen:</p>
  
  <pre><code>namespace RegressionMvc.Models
  {
    public class RegresDB_TableName
    {
       public string TableName { get; set; }
    }
    public class RegressDB_TableList
    {
       public List&lt;RegresDB_TableName&gt; RegresTableList { get; set; }
    }
  </code></pre>
  
  <p>}</p>
  
  <p>In the end, I'm trying to figure out the best way to handle DataSet results from Sql Server and how to make them back to an MVC View.</p>
  
  <p>I can probably go with jQuery and Json, meaning just convert the data fields to Json and return to JQuery, but I'm sure there are several ways to handle Sql based result sets.</p>
  
  <p>Thanks in advance for your advice....</p>
  
  <p>Best,
  Bob</p>