I'm having a problem with my code. My users occasionaly get Object reference not set to an instance of an object.
It occurs when the I try to get the results back for a stored procedure. I'm at a loss as to what to change.
FYI MyReader & MyCmd are declared in a global modual
Here's the stack trace:
It occurs when the I try to get the results back for a stored procedure. I'm at a loss as to what to change.
FYI MyReader & MyCmd are declared in a global modual
Here's the stack trace:
Code:
2: Error Description:Object reference not set to an instance of an object.
2: Source:System.Data
2: Stack Trace: at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
2: at System.Data.SqlClient.SqlCommand.ExecuteReader()
2: at WEBMIS.AdhocQuery.CheckDownload(Decimal GroupID) in F:\app-development\WebMIS\AdhocQuery.aspx.vb:line 229
2: at WEBMIS.AdhocQuery.Page_Load(Object sender, EventArgs e) in F:\app-development\WebMIS\AdhocQuery.aspx.vb:line 106
2: at System.Web.UI.Control.OnLoad(EventArgs e)
2: at System.Web.UI.Control.LoadRecursive()
2: at System.Web.UI.Page.ProcessRequestMain()
2: Target Site:System.Data.SqlClient.SqlDataReader ExecuteReader(System.Data.CommandBehavior, System.Data.SqlClient.RunBehavior, Boolean)
Code:
227 If cnMIS.State = ConnectionState.Closed Then cnMIS.Open()
228 MyCmd = New SqlCommand("usp_HasDownloaded", cnMIS)
229 With MyCmd
230 .CommandTimeout = 8000
231 .CommandType = CommandType.StoredProcedure
232 .Parameters.Add(New SqlParameter("@GroupID", SqlDbType.Decimal, 9)).Value = GroupID
233 .Parameters.Add(New SqlParameter("@MyDate", SqlDbType.DateTime, 9)).Value = FormatDateTime(Date.Now, DateFormat.ShortDate)
234 MyReader = .ExecuteReader()
235 End With