Solved

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

Posted on 2006-06-16
6
5,488 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

Independent Software Vendors: 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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 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