title: C# ASP.NET Simple Select Problem
body: <p>I am having a problem is getting a value from mysql using c#. The connection string is right, but it throws the following error: Invalid attempt to access a field before calling Read()</p>
  
  <p>Can anyone tell me the problem which occurs in the code below</p>
  
  <pre><code>            string strConnection = ConfigurationSettings.AppSettings["ConnectionString"];
              MySqlConnection connection = new MySqlConnection(strConnection);
              MySqlCommand command = connection.CreateCommand();
              MySqlDataReader reader;
              command.CommandText = "SELECT application_domain_name FROM `test`.`application_domains` WHERE idapplication_domains = " + reference;
              connection.Open();
              reader = command.ExecuteReader();
  
              lblApplicationDomain.Text = reader.GetString(0);
  
              connection.Close();
  </code></pre>