title: asp.net MVC3 C#: Passing query as a parameter and displaying result
body: <p>I am new to asp.net , C# and building an MVC application based on the popular Music Store application.
  I have my basic navigation ready and I have reached a point where I am drawing a complete blank. Basically, my asp page displays a SQL query (which is saved in SQL DB on same machine)</p>
  
  <p>Need:
  I need to have a button next to this query which when clicked, connects to another DB through OLEDB, and runs the query and shows result in a pop up window. </p>
  
  <p>Questions:
  How do I pass the query (which is being fetched from DB) as a parameter to code below and How do I make the results pop up in a window.</p>
  
  <p>Can you please point me in correct direction. The code below is from a stand alson asp page which i used for testing connections etc. basically i need to pass the query as a parameter (replacing query seen below) and have the result in a pop window.</p>
  
  <pre><code>&lt;%@ Import Namespace="System.Data.OleDb" %&gt;
  &lt;%@ Import Namespace="System.Data.Odbc" %&gt;
  
  &lt;script runat="server"&gt;
  sub Page_Load
          Dim dbconn, sql, dbcomm, dbread
          dbconn = New OleDbConnection("Provider=xxxx;Password=xxxx;User ID=xxxx;Data Source=xxxx;Initial Catalog=xxxx;Port=xxxx;")
  dbconn.Open()
          sql = "Select ID from TABLE1"
          dbcomm = New OleDbCommand(sql, dbconn)
          dbread = dbcomm.ExecuteReader() &lt;%-- Call this method within oledbcommand--%&gt;
  
    If dbread.Read = False Then
                      MsgBox("No Data Check")
                  Else                    
                    Response.Write("&lt;table&gt;")
                      Do While dbread.Read()
                          Response.Write("&lt;tr&gt;")
                          Response.Write("&lt;td&gt;")
                          Response.Write(dbread(0))
                          Response.Write("&lt;/td&gt;")
                          Response.Write("&lt;/tr&gt;")
                      Loop
                    Response.Write("&lt;/table&gt;")
  
   End If
           dbconn.Close()
  
  end sub
  &lt;/script&gt;
  </code></pre>
  
  <p>ADDITIONAL DETAILS</p>
  
  <p>CONTROLLER CLASS
  .
  .</p>
  
  <pre><code>public ActionResult DisplayResult(String Qry)        
     {
         List&lt;QuerySet&gt; QueryToExecute = new List&lt;QuerySet&gt;();
         return View(QueryToExecute);    
  </code></pre>
  
  <p>VIEW that provides this contoller with DATA, this is query that is fetched from my SQL DB and should be executed to a separate DB on a separate server.</p>
  
  <pre><code>&lt;ul&gt; 
  @foreach (var ShowQueries in Model.Queriess)
  { 
      &lt;li&gt; 
         @Html.ActionLink(ShowQueries.Query, "DisplayResult", new { Qry = ShowQueries.Query }) 
      &lt;/li&gt; 
  } 
  </code></pre>
  
  <p>ISSUE: 
  How should I use a view named 'DisplayResult' which handles the query fetched by view above and executes it agaisnt another DB.
  I was hoping I can use a Webform view rather than a razor view but either way i am not able to pass the parameter
  Any ideas are appreciated</p>
  
  <p></p>