0
我有一個問題是從MySQL使用C#獲取值。連接字符串是正確的,但它引發以下錯誤:無效的嘗試調用讀前訪問一個字段()C#ASP.NET簡單選擇問題
誰能告訴我發生在下面的代碼
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();
參見:[一個媽媽的漏洞(http://xkcd.com/327/) – 2011-06-01 18:46:32