# Thursday, February 16, 2006

I wasn't aware of it, until now anyway...       

using (SqlConnection conn = new SqlConnection("your-connection-string"))
{
   string query = "SELECT * FROM T1; SELECT * FROM T2;";
   SqlCommand cmd = new SqlCommand(query, conn);
   
   conn.Open();
   SqlDataReader reader = cmd.ExecuteReader();
   do
   {
      while(reader.Read())
      {
         // read each row in the statement results.
      }
   }
   while(reader.NextResult()); // jump to the next statement results.
}

« Lnbogen Challenge: refactor exception handling  | Main |   Templating with Generics & Delegates »
Friday, February 17, 2006 1:49:08 AM (Jerusalem Standard Time, UTC+02:00)
I saw the NextResult() method before, but I didn't know what it did.
Nice!

Any idea how to do this on Oracle? It just throws an error at you if you try to pass a ';' to the command.
Comments are closed.