title: How do I get a data table from a select query done to Oracle and display it in my view in MVC?
body: <p>I want to be able to return a table in my oracle db and send it to be displayed in my view in my MVC structure. My code looks something like this for my model:</p>
  
  <pre><code>        public DataTable Show(int Poll_ID)
      {
  
          OleDbDataReader myOleDBDataReader = DBConn("SELECT * FROM MCQ_QUESTIONS WHERE Poll_ID = 1");
  
          DataSet dataSet = new DataSet();
  
          DataTable schemaTable = myOleDBDataReader.GetSchemaTable();
          DataTable dataTable = new DataTable();
  
          for (int cntr = 0; cntr &lt; schemaTable.Rows.Count; ++cntr)
          {
              DataRow dataRow = schemaTable.Rows[cntr];
              string columnName = dataRow["ColumnName"].ToString();
              DataColumn column = new DataColumn(columnName, dataRow.GetType());
              dataTable.Columns.Add(column);
          }
          myOleDBDataReader.Close();
          myOleDbConnection.Close();
          return dataTable;
  </code></pre>
  
  <p>But its not working. Any help is appreciated guys!! Code from my Controller class is as follows:</p>
  
  <pre><code>public ActionResult Details(int id)
      {
          PollModel poll = new PollModel();
          DataTable dt = new DataTable();
          dt = poll.Show(1);
          //ViewData["Poll"] = poll.Show();
          ViewData["Data"] = dt;
          //ViewData["Poll"] = "Testing";
          return View(dt);
      }
  </code></pre>
  
  <p>Code in my view is as follows :</p>
  
  <pre><code>    &lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %&gt;
  &lt;%@ Import Namespace = "MvcApplication3.Models" %&gt;
  &lt;%@ Import Namespace = "System.Data" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"&gt;
      Details
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  &lt;%= Html.Encode(ViewData["Data"])%&gt;
  
  &lt;/asp:Content&gt;
  </code></pre>