title: How can I pass DataReader/DataTable to view?
body: <p>I am new to MVC and trying to write a simple MVC 3 application which reads customer data inside a class in model and return it to view using controller. Reader shows it has rows but when load to table and pass to view as model, it is null. I need a simple solution to pass either a <code>DataTable</code> to view or <code>DataReader</code> to view where I can convert to <code>DataTable</code>.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>namespace MvcApplication3.Models
  {
      public class Customer
      {
          public DataTable GetCustomers(OdbcDataReader rds)
          {
              String ConString = "DSN=Northwind;Uid=;Pwd=;";
              String SQL = "SELECT * FROM CUSTOMERS";
              DataTable tbl = new DataTable();
  
              using (OdbcConnection con = new OdbcConnection(ConString))
              {
                  con.Open();
                  OdbcCommand cmd = new OdbcCommand(SQL, con);
                  rds = cmd.ExecuteReader();
              }
          }
  
      }
  }
  
  namespace MvcApplication3.Controllers
  {
      public class DefaultController : Controller
      {
          //
          // GET: /Default1/
  
          public ActionResult Index()
          {
              Customer cs = new Customer();
              OdbcDataReader rd = new OdbcDataReader();
              cs.GetCustomers(rd);
  
              DataTable tb = new DataTable();
              tb.Load(rd);
              return View(tb);
          }
      }
  }
  </code></pre>