Solved

Item cannot be found in the collection corresponding to the requested name or ordinal. wierd...

Posted on 2006-06-16
6
5,486 Views
Last Modified: 2010-10-05
I currently have a form that sends data to a page that sends it to the database,

//Form code

<form action="../Copy%20of%20flashsystem/addcomment.asp" method="post" name="commentform" onSubmit="MM_validateForm('Name','','R','Email','','NisEmail','Comment','','R');return document.MM_returnValue">
  <table width="0" border="0" cellspacing="0" cellpadding="3">
    <tr>
      <td width="38">Name:</td>
      <td width="251"><input type="text" name="Author"></td>
    </tr>
    <tr>
      <td>Email:</td>
      <td><input type="text" name="Author_Email"></td>
    </tr>
    <tr>
      <td colspan="2">Comments:
      <textarea name="Comment" cols="45" rows="7"></textarea></td>
    </tr>
    <tr>
      <td colspan="2"><input  name="FlashID" type="hidden" value="<% = lngRecordNo %>" >
<input type="submit" name="Submit" value="Submit"></td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>

It sends it to a page called addcomment.asp

//addcomment.asp

<%
'Dimension variables
Dim adoCon              'Holds the Database Connection Object
Dim rs   'Holds the recordset for the new record to be added
Dim strSQL               'Holds the SQL query to query the database

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("flashdb.mdb")

'Create an ADO recordset object
Set rs = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblComments.Author, tblComments.Comment, tblComments.Author_Email FROM tblComments;"

'Set the cursor type we are using so we can navigate through the recordset
rs.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rs.LockType = 3

'Open the recordset with the SQL query
rs.Open strSQL, adoCon

'Tell the recordset we are adding a new record to it
rs.AddNew

'Add a new record to the recordset
rs.Fields("Author") = Request.Form("Author")
rs.Fields("Author_Email") = Request.Form("Author_Email")
rs.Fields("Comment") = Request.Form("comment")
rs.Fields("FlashID") = Request.Form("FlashID")

'Write the updated recordset to the database
rs.Update

'Reset server objects
rs.Close
Set rs = Nothing
Set adoCon = Nothing

'Redirect to the guestbook.asp page
Response.Redirect "FlashPage.asp"
%>

I am getting this error message when i click the submit button:

ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

/flashsystem/addcomment.asp, line 35

How can i fix this? im sure its really simple and im overlooking something...
0
Comment
Question by:cookiejest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 16922100
Check your field names - something doesn't match up.
0
 

Author Comment

by:cookiejest
ID: 16922161
I cant see an error can you?
0
 
LVL 31

Accepted Solution

by:
alorentz earned 125 total points
ID: 16922452
Yeah, you only select a couple fields (tblComments.Author, tblComments.Comment, tblComments.Author_Email )

But then you try to add FlashID...

You should do this:

strSQL = "SELECT* FROM tblComments;"


OR

strSQL = "SELECT* FROM tblComments where 1=0;"  '<--- 'EMPTY RECORDSET

0
 
LVL 31

Expert Comment

by:alorentz
ID: 16924140
Why a grade C?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question