title: error: Does not exist in the current context
body: <p>I am trying to access a MySql database in a C# console application, just to get it to print a couple of values to make sure it connects. It keeps giving me a "the name "reader" does not exist in the current context" error.</p>
  
  <p>This is the code I'm using...</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using MySql.Data.MySqlClient;
  using System.Data;
  
  namespace sql_test
  {
      class Program
      {
          static void Main(string[] args)
          {
  
              string connectionString =
                      "Server=localhost;" +
                      "Database=DBname;" +
                      "User ID=DBID;" +
                      "Password=DBpass;" +
                      "Pooling=false;";
              IDbConnection dbcon;
              dbcon = new MySqlConnection(connectionString);
              try
              {
                  dbcon.Open();
              }
              catch(Exception ex1)
              {
                  Console.WriteLine(ex1.Message);
              }
              IDbCommand dbcmd = dbcon.CreateCommand();
  
              string sql =
                  "SELECT RoomId, RoomName " +
                  "FROM Resources";
              dbcmd.CommandText = sql;
              try
              {
                  IDataReader reader = dbcmd.ExecuteReader();
              }
              catch (InvalidOperationException ex2)
              {
                  Console.WriteLine(ex2.Message);
              }
  
              while (reader.Read())
              {
                  string roomID = (string)reader["RoomId"];
                  string roomName = (string)reader["RoomName"];
                  Console.WriteLine("Name: " +
                        roomID + " " + roomName);
              }
              // clean up
              reader.Close();
              reader = null;
              dbcmd.Dispose();
              dbcmd = null;
              dbcon.Close();
              dbcon = null;
          }
      }
  }
  </code></pre>
  
  <p>obviously i have changed the mysql login password and server names etc. but other wise its all the same...</p>
  
  <p>the only "reader" that doesn't have the error is the one after IDataReader about line 39.</p>
  
  <p>Any help would be much appreciated.</p>