Hi
I am a newbie to ASP.NET. I developed a web page (project type is web application) and I keep getting this error.
B]Error message :
"System.AccessViolation Exception attempted to read or write protected memory. this is often an indication that other memory is corrupt.... "[/b]
These are all the platform info :
Visual Studio 2005 (VB.NET) and ASP.NET 2.0.
I m using Microsoft.NET provider for ORACLE (System.data.Oracleclient).
I am using Microsoft Enterprise Library version 3.1 (May 2007) Data Access Application block for database operations.
The backend database is ORACLE 10g ver 10.2 and ORACLE client is 9.2 on the web server.
The webserver resides on a Windows 2000 server.
I keep getting this error pretty often on page load (where I make a database call). Sometimes the error does not show up and the page loads properly. Sometimes the error goes away after a period of time, but for most parts, the page literally becomes non-responsive after receving this error listed below. This literally cripples the web page I developed. I am able to bring the page back up and load it properly by restarting IIS. One more thing is this error mainly shows up only on the server and not on my local development machine (running XP Pro). Everything seems to work fine on my local machine until I deploy this page and run it on the server.
Error message :
"System.AccessViolation Exception attempted to read or write protected memory. this is often an indication that other memory is corrupt.... "
then a long list of functions related to database calls. My code script is given below : Specifically it fails (sometimes) at the point where I make the db.ExecuteScalar call. Please note that this error does not show up all the time, sometimes the page loads without any problems and with the correct value returned by ExecuteScalar.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim sql As String
Dim sEom As String
Try
If Not Page.IsPostBack Then
Dim db As Database = DatabaseFactory.CreateDatabase("DataSource")
'Get the financial period
sql = "select fin_period from fin_cal" ' this returns only one row
Using dbCommand As DbCommand = db.GetSqlStringCommand(sql)
sEom = CType(db.ExecuteScalar(dbCommand), String)
lblFinper.Text = sEom.ToString.Trim
If Not (dbCommand Is Nothing) Then
dbCommand.Dispose()
End If
End Using
End If
Catch ex As System.Data.OracleClient.OracleException
lblMessage.Text = "Database Error."
Response.Write(ex.ToString)
Catch ex As Exception
lblMessage.Text = "System Error."
Response.Write(ex.ToString)
End Try
End sub
Could anyone help me out, please ? It is critical that I make this work. I have also posted my code below. Please let me know whether I am making any mistake in code or in the way I am making Microsoft Enterprise Library Data Access application block calls. Your help on this would be greatly appreciated and a lifesaver for me!!
Thanks in advance.