Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ADODB.Field (0x800A0BCD) - please help

New Here ,
Aug 19, 2009 Aug 19, 2009

Hi

I'm trying to create a page where I can create a new category with one form (form1) and also amend and delete using another form (form2).

However when I preview in browser, I get:

ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/edufurniture/new_product.asp, line 209

I've underlined in bold line 209, which is near the end of the code below.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/conn_edufurniture.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
  If condition = "" Then
    MM_IIf = ifFalse
  Else
    MM_IIf = ifTrue
  End If
End Function
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_conn_edufurniture_STRING
    MM_editCmd.CommandText = "INSERT INTO osc_product_categories (categories_name, catergories_image, catergories_alt) VALUES (?, ?, ?)"
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("cat_name")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 45, Request.Form("cat_image")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("cat_alt")) ' adVarWChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "new_product.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>
<%
' *** Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) = "form2" And CStr(Request("MM_recordId")) <> "") Then

  If (Not MM_abortEdit) Then
    ' execute the delete
    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_conn_edufurniture_STRING
    MM_editCmd.CommandText = "DELETE FROM osc_product_categories WHERE categories_id = ?"
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, Request.Form("MM_recordId")) ' adDouble
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    ' Dim MM_editRedirectUrl
    MM_editRedirectUrl = "new_product.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If

End If
%>
<%
If (CStr(Request("MM_update")) = "form2") Then
  If (Not MM_abortEdit) Then
    ' execute the update
    'Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_conn_edufurniture_STRING
    MM_editCmd.CommandText = "UPDATE osc_product_categories SET categories_name = ?, catergories_image = ?, catergories_alt = ? WHERE categories_id = ?"
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("cat_name")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 45, Request.Form("cat_image")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("cat-alt")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    ' Dim MM_editRedirectUrl
    MM_editRedirectUrl = "new_product.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>
<%
Dim rec_categories
Dim rec_categories_cmd
Dim rec_categories_numRows

Set rec_categories_cmd = Server.CreateObject ("ADODB.Command")
rec_categories_cmd.ActiveConnection = MM_conn_edufurniture_STRING
rec_categories_cmd.CommandText = "SELECT * FROM osc_product_categories"
rec_categories_cmd.Prepared = true

Set rec_categories = rec_categories_cmd.Execute
rec_categories_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rec_categories_numRows = rec_categories_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
@import url("_admin/admin_css.css");
-->
</style>
</head>

<body>
<p>Add New Category
</p>
<p> </p>
<form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
<fieldset>


<label for="Category Name"> New Category name:
<input name="cat_name" type="text" class="form_field" size="30" maxlength="50" />
</label>

<label for="Category Image"> New Category Image:
<input name="cat_image" type="text" class="form_field" size="30" maxlength="50" />
</label>

<label for="Category Image"> New Category alt text:
<input name="cat_alt" type="text" class="form_field" size="30" maxlength="50" />
</label>

</fieldset>
<input name="Submit" type="submit" value="Submit" />
<input type="hidden" name="MM_insert" value="<%=cStr(Request.Form("cat_alt"))%>" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
<p>Existing Categories</p>
<form id="form2" name="form2" method="POST" action="<%=MM_editAction%>">
  <table width="950`" border="1" cellspacing="1" cellpadding="1">
    <tr>
      <th width="187" scope="col">Catergory ID</th>
      <th width="223" scope="col">Catergory Name</th>
      <th width="245" scope="col">Category Image</th>
      <th width="122" scope="col">Category Alt</th>
      <th width="122" scope="col">Amend/Delete</th>
    </tr>
    <tr>
      <%
While ((Repeat1__numRows <> 0) AND (NOT rec_categories.EOF))
%>
      <td><label><%=(rec_categories.Fields.Item("categories_id").Value)%>        </label></td>
      <td><label>
        <input type="text" name="cat_name2" id="cat_name" />
        <%=(rec_categories.Fields.Item("categories_name").Value)%></label></td>
      <td><label>
      <img src="_images/<%=(rec_categories.Fields.Item("catergories_image").Value)%>" width="100" height="34" />
<input type="text" name="cat_image2" id="cat_image" />
        <%=(rec_categories.Fields.Item("catergories_image").Value)%>      </label></td>
      <td><input type="text" name="cat-alt" id="cat-alt" />
        <%=(rec_categories.Fields.Item("catergories_alt").Value)%></td>
      <td><label>
        <input type="submit" name="cat-Amend" id="cat-Amend" value="Amend" />
        <input type="submit" name="cat-delete" id="cat-delete" value="Delete" />
      </label></td>
      <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rec_categories.MoveNext()
Wend
%>
    </tr>
  </table>
  <input type="hidden" name="MM_recordId" value="<%= rec_categories.Fields.Item("categories_id").Value %>" />
  <input type="hidden" name="MM_delete" value="form2" />
  <input type="hidden" name="MM_update" value="form2" />
</form>
<p> </p>
<p> </p>
<p> </p>

</body>
</html>
<%
rec_categories.Close()
Set rec_categories = Nothing
%>

any help would be gratefully received.

John

TOPICS
Server side applications
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 19, 2009 Aug 19, 2009

The error could mean that the query has returned 0 rows. Which line is 209? Remember to calculate the line number you need to consider any lines added in any included files.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 19, 2009 Aug 19, 2009

Try wrapping your bottom form in a Show If Recordset Not Empty server behavior:

<%
While ((Repeat1__numRows <> 0) AND (NOT rec_categories.EOF))
%>

YOUR BOTTOM FORM

<% End If ' end Not rec_categories.EOF Or NOT rec_categories.BOF %>

Ken Ford
Adobe Community Expert - Dreamweaver/ColdFusion
Adobe Certified Expert - Dreamweaver CS4
Adobe Certified Expert - ColdFusion 8
Fordwebs, LLC
http://www.fordwebs.com
http://www.cfnoob.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 21, 2009 Aug 21, 2009

Hi

Thanks for the help so far.

The code still causes a problem:

Microsoft VBScript compilation  (0x800A0400)
Expected statement
/edufurniture/new_product.asp, line 216
End If ' end NOT rec_categories.EOF Or NOT rec_categories.BOF

I've inserted the code as follows:

<%While ((Repeat1__numrows <> 0) AND (NOT rec_categories.EOF)) %>

<form id="form2" name="form2" method="POST" action="<%=MM_editAction%>">
  <table width="950`" border="1" cellspacing="1" cellpadding="1">
    <tr>
      <th width="187" scope="col">Catergory ID</th>
      <th width="223" scope="col">Catergory Name</th>
      <th width="245" scope="col">Category Image</th>
      <th width="122" scope="col">Category Alt</th>
      <th width="122" scope="col">Amend/Delete</th>
    </tr>
    <tr>
      <%
While ((Repeat1__numRows <> 0) AND (NOT rec_categories.EOF))
%>
      <td><label><%=(rec_categories.Fields.Item("categories_id").Value)%>        </label></td>
      <td><label>
        <input type="text" name="cat_name2" id="cat_name" />
        <%=(rec_categories.Fields.Item("categories_name").Value)%></label></td>
      <td><label>
      <img src="_images/<%=(rec_categories.Fields.Item("catergories_image").Value)%>" width="100" height="34" />
<input type="text" name="cat_image2" id="cat_image" />
        <%=(rec_categories.Fields.Item("catergories_image").Value)%>      </label></td>
      <td><input type="text" name="cat-alt" id="cat-alt" />
        <%=(rec_categories.Fields.Item("catergories_alt").Value)%></td>
      <td><label>
        <input type="submit" name="cat-Amend" id="cat-Amend" value="Amend" />
        <input type="submit" name="cat-delete" id="cat-delete" value="Delete" />
      </label></td>
      <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rec_categories.MoveNext()
Wend
%>
    </tr>
  </table>
  <input type="hidden" name="MM_recordId" value="<%= rec_categories.Fields.Item("categories_id").Value %>" />
  <input type="hidden" name="MM_delete" value="form2" />
  <input type="hidden" name="MM_update" value="form2" />
</form>
<% End If ' end NOT rec_categories.EOF Or NOT rec_categories.BOF %>   ----------Line 216

John

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 21, 2009 Aug 21, 2009
LATEST

Remove this one:

<tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rec_categories.EOF))
%>
<td>

So it should be:

<tr>
<td>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines