'/' 應用程式中發生伺服器錯誤。

Invalid attempt to access a field before calling Read()

描述: 在執行目前 Web 要求的過程中發生未處理的例外情形。請檢閱堆疊追蹤以取得錯誤的詳細資訊,以及在程式碼中產生的位置。

例外詳細資訊: MySql.Data.MySqlClient.MySqlException: Invalid attempt to access a field before calling Read()

原始程式錯誤:


行 178:		 dr=cmd.ExecuteReader()
行 179:		 dr.read()
行 180:		    product_id.Text=dr.Item("product_id")
行 181:			description.Text=dr.Item("description")
行 182:				

原始程式檔: F:\SMARTANT\product\product_detail2.aspx    行: 180

堆疊追蹤:


[MySqlException (0x80004005): Invalid attempt to access a field before calling Read()]
   MySql.Data.MySqlClient.MySqlDataReader.GetFieldValue(Int32 index, Boolean checkNull) +343
   MySql.Data.MySqlClient.MySqlDataReader.GetValue(Int32 i) +57
   MySql.Data.MySqlClient.MySqlDataReader.get_Item(Int32 i) +10
   MySql.Data.MySqlClient.MySqlDataReader.get_Item(String name) +24
   ASP.product_product_detail2_aspx.Page_Load(Object sender, EventArgs e) in F:\SMARTANT\product\product_detail2.aspx:180
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627


版本資訊: Microsoft .NET Framework 版本:2.0.50727.3625; ASP.NET 版本:2.0.50727.3618