-
November 25th, 2005, 06:07 AM
#1
Error: Attempted to read or write protected memory (while filling a datareader)
Hello all,
I am having a problem with some code, and haven't been able to work it out on my own . Hopefully one of you nice people can help me clear this up .
Here is the code:
Code:
Private Sub BindSummary()
Dim _sql As String = "SELECT * FROM [qry_Project_ProjectedFee_Summary] WHERE [Month/Year] = ? ORDER BY [Name]"
Dim _dbConn As New OleDbConnection(ConfigurationManager.ConnectionStrings("MyDbConn1").ToString)
Dim _dbComm As New OleDbCommand(_sql, _dbConn)
_dbComm.Parameters.Add(New OleDbParameter("[Month/Year]", CDate(lstCurrentMonth.SelectedItem.Value)))
_dbComm.Connection.Open()
Summary.DataSource = _dbComm.ExecuteReader
Summary.DataBind()
_dbComm.Connection.Close()
' Get Totals
_sql = "SELECT SUM(Total) AS Total, SUM(Claimed) AS Claimed, SUM(Initial) - SUM(SubInitial) AS Initial" & _
", SUM(Actual) - SUM(Actual) AS Actual, SUM(Revised) - SUM(SubRevised) AS Revised" & _
", SUM(Future1) - SUM(SubFuture1) AS Future1, SUM(Future2) - SUM(SubFuture2) AS Future2" & _
", SUM(Remaining) - SUM(SubRemaining) AS Remaining " & _
"FROM(qry_Project_ProjectedFee_Summary) WHERE [Month/Year] = ?"
_dbComm.CommandText = _sql
_dbComm.Parameters.Add(New OleDbParameter("[Month/Year]", CDate(lstCurrentMonth.SelectedItem.Value)))
_dbComm.Connection.Open()
Dim _dbRead As OleDbDataReader = _dbComm.ExecuteReader()
_dbComm.Connection.Close()
_CurrentMonth = lstCurrentMonth.SelectedItem.Value
_dbRead = Nothing
_dbComm = Nothing
_dbConn = Nothing
End Sub
The error occurs at the code in bold.
This is the exact error:
Code:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source Error:
Line 89: _dbComm.Connection.Open()
Line 90:
Line 91: Dim _dbRead As OleDbDataReader = _dbComm.ExecuteReader()
Line 92:
Line 93: _dbComm.Connection.Close()
Source File: C:\Inetpub\pmacs\FeeProjection.aspx Line: 91
Stack Trace:
[AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
System.Data.Common.IAccessor.ReleaseAccessor(IntPtr hAccessor, Int32& pcRefCount) +0
System.Data.OleDb.RowBinding.Dispose() +90
System.Data.OleDb.Bindings.Dispose() +29
System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior behavior, Boolean throwifnotsupported) +46
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +16
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +106
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +111
System.Data.OleDb.OleDbCommand.ExecuteReader() +6
ASP.FeeProjection_aspx.BindSummary() in C:\Inetpub\pmacs\FeeProjection.aspx:91
ASP.FeeProjection_aspx.lstCurrentMonth_SelectedIndexChanged(Object sender, EventArgs e) in C:\Inetpub\pmacs\FeeProjection.aspx:129
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e) +105
System.Web.UI.WebControls.ListBox.RaisePostDataChangedEvent() +132
System.Web.UI.WebControls.ListBox.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +7
System.Web.UI.Page.RaiseChangedEvents() +137
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5330
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50215.44; ASP.NET Version:2.0.50215.44
It seems like no matter what I do, the .ExecuteReader method always fails.
I have tried creating a new command object for the second execution of executereader, but I still had the same error.
Any help, much appreciated
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|