Here is my code that caused the
Exception information:
Exception type: AccessViolationException
Exception message: Attempted to read or write protected memory.
and the server admn suggested that there may be a memory leak or memory location are unintentionally modified due to programming errors. here is my code please let me know if there is a way to improve the code.
code behind:
---------------
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
End Sub
Sub BindData()
Dim srtOrder As String = SortList1.SelectedValue
Dim drDirection As String = DirectionList.SelectedValue
' Dim connectionString As String
Dim oOracleConn As OracleConnection
' Dim oOracleConn As OleDbConnection
Dim connectionString As String = ConnectionStrings("ConnectionString").ConnectionString
oOracleConn = New OracleConnection(connectionString)
'oOracleConn = New OleDbConnection(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 ")
'''''Here only change the letting Number
.Append(" AND (l.letting = '08062701') AND INSTR (pr.pjprjnum, p.cprojnum) > 0 ")
'.Append("ANd pr.pjprjnum <> '5703-42 / HSIP 5707(007)'"
.Append(" GROUP BY a.addend,a.dateadd, a.contid,l.letting, p.cprojnum,p.prroute, a.adescr, pjprjnum ")
' .Append(" ORDER BY 1 ")
.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)
'Dim adAddenda As New OleDbDataAdapter(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 Clas
------aspx page---
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="addenda.aspx.vb" Inherits="addtest" %>
<html xmlns="
>
<head>
<link href="css/tecsup-print.css" rel="stylesheet" type="text/css" />
<title> </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
<meta name="description" content="Addenda List" />
<meta name="Items" content="Addenda List,Addenda List For Current Project" />
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 99%; background-color: #e6e6fa">
<tr>
<td style="width: 100px; text-align: left;">
<span style="color: red"><strong>
CAUTION:<br />
</strong><span style="color: #000000"></span></span>
</td>
</tr>
</table>
<br />
This site has a list of addenda issued for the current letting but does not
have the text of the addenda.The actual addenda are either mailed or faxed out to
the planholders of record when they are issued.It is the contractor's responsibility
to determine which, if any, addenda pertains to any project they may be bidding.
Failure by the bidder to acknowledge an addendum could result in a bidding being
rejected as irregular. <br />
<br />
<table style="width: 99%; background-color: #FFEFD5;">
<tr>
<td style=" width:47%">
<span style="color: black">
<br />
<br />
Total Number of addenda found:<asp:Label ID="lblTotal" runat="server" Text="Label" Width="112px" Font-Bold="True" ForeColor="Red"></asp:Label></span><strong>
</strong>
</td>
<td style="width: 22%">
<br />
<asp:Label ID="lblSrt" runat="server" Text="Sort By:" Width="82px"></asp:Label>
<asp

ropDownList id="SortList1" Runat="server" >
<asp:ListItem Text="S.P. Number" Value="stateproject" />
<asp:ListItem Text="Contract Id" Value="contid" />
<asp:ListItem Text="Issue Date" Value="dateadded"/>
<asp:ListItem Text="Letting Date" Value="Lett_date"/>
</asp

ropDownList></td>
<td style="width: 18%">
<div id="SrtOrd">
<br />
<asp

ropDownList id="DirectionList" Runat="server">
<asp:ListItem Text="Ascending" Value="Asc" />
<asp:ListItem Text="Descending" Value="Desc" />
</asp

ropDownList>
<asp:Button ID="Button1" runat="server" Text="Go!" /></div>
</td>
</tr>
</table>
<asp:GridView ID="gvaddenda" runat="server" CellPadding="4" ForeColor="#333333" Width="99%" HorizontalAlign="Left" AutoGenerateColumns="False">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" Font-Size="Small" HorizontalAlign="Left" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" Font-Size="Small" HorizontalAlign="Left" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" Font-Size="X-Small" HorizontalAlign="Left" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<columns>
<asp:BoundField DataField="stateproject" HeaderText="State Project Num">
<ItemStyle Font-Size="11px" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="minnesotaprojectnumber" HeaderText="MN Project Num">
<ItemStyle Font-Size="11px" />
</asp:BoundField>
<asp:BoundField DataField="contid" HeaderText="Contract Id">
<ItemStyle Font-Size="11px" />
</asp:BoundField>
<asp:BoundField DataField="addendanum" HeaderText="Addend. No">
<ItemStyle Font-Size="11px" />
</asp:BoundField>
<asp:BoundField DataField="dateadded" HeaderText="Issue Date">
<ItemStyle Font-Size="11px" />
</asp:BoundField>
<asp:BoundField DataField="Descr" HeaderText="Brief Description Of Addenda">
<ItemStyle Font-Size="11px" />
</asp:BoundField>
<asp:BoundField DataField="Lett_date" HeaderText="Letting Date">
<ItemStyle Font-Size="11px" />
</asp:BoundField>
</columns>
</asp:GridView>
<br />
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</div>
</form>
</body>
</html>