Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attempted to read or write protected memory

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US
The code breaks on line number 55. Please help. I did search on google but did not get a clear answer. hoping on this forum someone will give me a clue how I can fix this.
thanks

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: the code breaks on line nubmer 55
Line 55: adAddenda.Fill(dsAddenda, "AddendaList")


Line 53:
Line 54: 'fill the dataset with the result of our query from the specified command
Line 55: adAddenda.Fill(dsAddenda, "AddendaList")
Line 56:
Line 57: 'Bind the DataSet to the GridView

---------------------------
my code

Imports System.Data
Imports System.Data.OracleClient
Imports System.Configuration.ConfigurationManager
Partial Class addtest
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindData()
End If
'.Append("ANd pr.pjprjnum <> '5703-42 / HSIP 5707(007)'"
End Sub

Sub BindData()
Dim srtOrder As String = SortList1.SelectedValue
Dim drDirection As String = DirectionList.SelectedValue


'Dim oOracleConn As OracleConnection
Dim connectionString As String = ConnectionStrings("ConnectionString").ConnectionString
Dim oOracleConn As OracleConnection = New OracleConnection(connectionString)


Dim strStringBuilder As StringBuilder
strStringBuilder = New StringBuilder
With strStringBuilder
.Append(" SELECT DISTINCT p.cprojnum, p.cprojnum || NVL2 (TRIM (p.prroute), '(' || p.prroute || ')', NULL) AS stateproject, ")
.Append(" TRIM (SUBSTR (pr.pjprjnum, INSTR (pr.pjprjnum, '/') + 1) ) AS minnesotaprojectnumber, ")
.Append(" a.contid, LTRIM (a.addend, 0) addendanum, TO_CHAR (a.dateadd, 'MM/DD/YYYY') AS dateadded, (a.adescr) as Descr, ")
.Append(" substr(l.letting,3,2)||'-'|| substr(l.letting,5,2)||'-'|| substr(l.letting,1,2)Lett_date ")
.Append(" FROM addend a, letprop l, proposal p, propproj pp, project pr ")
.Append(" WHERE a.contid = p.contid AND pp.contid = p.contid AND pp.pcn = pr.pcn AND l.lcontid = p.contid ")
.Append(" AND (l.letting = '08062701') AND INSTR (pr.pjprjnum, p.cprojnum) > 0 ")
.Append(" GROUP BY a.addend,a.dateadd, a.contid,l.letting, p.cprojnum,p.prroute, a.adescr, pjprjnum ")
.Append(" ORDER BY " & srtOrder & " " & drDirection)
End With

'create a new command and pass our sql statement and our connection object.
Dim cmdAddenda As New OracleCommand()
' Dim cmdAddenda As New OleDbCommand()
cmdAddenda.Connection = oOracleConn
cmdAddenda.CommandType = CommandType.Text
cmdAddenda.CommandText = strStringBuilder.ToString

'open the connection
'oOracleConn.Open()

'create a new sqladapter and set its command object with our sqlcommand
Dim adAddenda As New OracleDataAdapter(cmdAddenda)

'create a new dataset to hold our data
Dim dsAddenda As New DataSet


'fill the dataset with the result of our query from the specified command
adAddenda.Fill(dsAddenda, "AddendaList")

'Bind the DataSet to the GridView
gvaddenda.DataSource = dsAddenda
gvaddenda.DataBind()


'Close the connection
oOracleConn.Close()
lblTotal.Text = dsAddenda.Tables("AddendaList").Rows.Count.ToString
If lblTotal.Text = "0" Then
SortList1.Visible = False
DirectionList.Visible = False
Button1.Visible = False
lblSrt.Visible = False
End If

End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
BindData()
End Sub

End Class

 
Might be a red herring, but where are you opening the DataAdapter?
 
thank you jbenson001 for those two links. One of th suggestion is to set
"Distributed Transaction Coordinator (MS DTC) service Startup is set to start automatically."

How can I do this? How can I set tof MS DTC to start automatically?

Do I need to do this in my code or on the server....I do not have any clue with this please help.

thanks
 
I found out how to set "Distributed Transaction Coordinator (MS DTC) service Startup is set to start automatically."

Does this have any effect on the other applications when we change the setting to Automatic. I believe this needs to be done on the server..

thank you for the help
 
now "Distributed Transaction Coordinator (MS DTC) service Startup is set to start automatically." but I am still getting the same error message. It is really furstrating and the weird thing is this error only appears on the production server. I have the same application and I do not see any error or excetions on the dev. server. How can this be? I am sure someone out there experiece the same problem...
 
If the same code is working on another box and you are retrieving the data from the same database (that is EVERYTHING else is the same), you may want to check the memory (real and/or virtual) on the production server.

It is possible that when you do a DataSet.Fill(), a bad portion of memory is being used causing a problem, but otherwise the faulty memory is going undetected.

Make sure your virtual memory is set up to be between 2x and 2.5x physical RAM. You may want to drop the virtual memory, reboot, and then reset it to 2.5x physical (So if you have 2 Gig RAM, set VM to 4 ~ 5 Gig). You'll probably ahve to reboot a second time. During this time, a Disk Defrag may be a good thing too so the VM is contiguous.

If you are using a different database, does the data server have enough space for the temporary table that gets formed? Often I've seen test servers have 10% of the data (or less) that the prod server does, and it works fine, but once the full load is put upon it, it acts up.

The question came up earlier about Opening the DataAdapter... technically you don't have to manually open the DataAdapter but I find it best to always do the following fragment:

try {
if (_connObject.State != ConnectionState.Open) {
_connObject.Open();
}
_dataAdapter.Fill(_dataSet,_dataTable);
}
catch (OracleException ex) {
// Some handling of the error
}
finally {
_connObject.Close();
}
 
Forgot, do the Defrag _after_ the drop, and _before_ the creation of the VM
 
Thank you NESWalt for the tips and I will try out your sugesstion and I will let you know the final outcome. yes, I am getting the data from the same database. once again thank you for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top