title: SQL Nested Queries in C# and Connection Open Problem
body: <p>I have three tables and my requirement is to fetch their records by using the parent record of each table.</p>
  
  <p>So I have three queries. Here is a code sample:</p>
  
  <p>First Query</p>
  
  <pre><code>SQLConnection con = new SQLConnection("connectionstring");
  
  SQLCommand cmd1 = new SQLCommand (1stQuery,con);
  SQLDataReader rs1 = cmd1.DataReader();
  
  while (rs1.Read()) {
  
  // Making 2nd Query, 2nd Query is using 1st Query result
  
  SQLCommand cmd2 = new SQLCommand(2ndQuery,con);
  SQLDataReader rs2 = cmd2.DataReader();
  
  while (rs2.Read()){
  
  //Making 3rd Query using 2nd Query result
  }
  }
  </code></pre>
  
  <p>It gives the error that there is already an open DataReader. I dont want to close the SQL connection and open it for each query, as this is bad for performance.</p>
  
  <p>I want to use only one SQL Connection for all the queries.</p>