Help! Operation is not allowed in this context.

  • Thread starter Thread starter ronaldlee
  • Start date Start date
R

ronaldlee

Hi, I got an error message - Operation is not allowed in this context.
It said the error comes from the line objRS.Close()
Anyone have any ideas why? Thanks a lot.

Here is part of the code:

Dim strConnectionString As String =
"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=c:\test.mdb"
objConn = New ADODB.Connection
objConn.Open(strConnectionString)
objRS = New ADODB.Recordset
objRS.ActiveConnection = oCn
objRS.LockType = ADODB.LockTypeEnum.adLockOptimistic
objRS.CursorType = ADODB.CursorTypeEnum.adOpenDynamic
objRS.Open("SELECT * FROM Customers WHERE CustomerID = " &
Session("CustomerID"), objConn)

' DO SOMETHING HERE'

objRS.Close()

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
I think the answer might lie in the unseen 'DO SOMETHING HERE' code. What
are you doing with objRS in that code? Are you doing any
adds/deletes/updates?

Terri Morton
MVP ASP/ASP.NET
 
here is the code of 'DO SOMETHING'

objRS.Open("SELECT * FROM Customers WHERE CustomerID = " &
Session("CustomerID"), objConn)
%>
<div class="pageSectionHead">Billing
details</div>
<div class="pageSection">
<form name="details" action="default.aspx" method="post"
onSubmit="return check_billing();">

<input name="p" type="hidden" value="checkout" />
<input name="op" type="hidden" value="delivery" />
<table border="0" cellpadding="6" cellspacing="0"
class="tableGeneric">

<tr>
<td colspan="2"><p class="tableSection">Billing
address</p></td>
</tr>
<tr>
th width="25%" nowrap="nowrap">House name/number: <span
class="required">*</span></th>

<td><input type="text" name="billing_house"
value="<%=IIF(IsDBNull(objRS.Fields.Item("Customer_Address_Line1").Value),
Nothing, objRS.Fields.Item("Customer_Address_Line1").Value)%>"
size="30" maxlength="60" /></td>
</tr>
<tr>
<th width="25%" nowrap="nowrap">Street name:
<span class="required">*</span></th>
<td><input type="text" name="billing_street"
value="<%=IIF(IsDBNull(objRS.Fields.Item("Customer_Address_Line2").Value),
Nothing, objRS.Fields.Item("Customer_Address_Line2").Value)%>"
size="50" maxlength="50" /></td>
</tr>
<tr>
<th width="25%" nowrap="nowrap">Area
name:</th>
<td><input type="text" name="billing_area"
value="<%=IIF(IsDBNull(objRS.Fields.Item("Customer_Address_Line3").Value),
Nothing, objRS.Fields.Item("Customer_Address_Line3").Value)%>"
size="50" maxlength="50" /></td>
</tr>
<tr>
<th width="25%" nowrap="nowrap">City/Town:
<span class="required">*</span></th>
<td><input type="text" name="billing_town"
value="<%=IIF(IsDBNull(objRS.Fields.Item("Customer_Address_Line4").Value),
Nothing, objRS.Fields.Item("Customer_Address_Line4").Value)%>"
size="50" maxlength="50" /></td>
</tr>
<tr>
<th width="25%" nowrap="nowrap">County: <span
class="required">*</span></th>
<td><%
Response.Write(generate_county_list("billing_county",
objRS.Fields.Item("Customer_Address_Line5").Value,
0))%></td>
</tr>
<tr>
<th width="25%" nowrap="nowrap">Postcode:
<span class="required">*</span></th>
<td><input name="billing_postcode"
type="text"
value="<%=IIF(IsDBNull(objRS.Fields.Item("Customer_Address_Line6").Value),
Nothing, objRS.Fields.Item("Customer_Address_Line6").Value)%>"
size="10" maxlength="8" /></td>
</tr>
</table>
<%
objRS.Close()

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
What does the generate_county_list() function do? If you temporarily remove
that bit of code does the error go away?

Terri Morton
MVP ASP/ASP.NET
 
Back
Top