?
Solved

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

Posted on 2006-06-16
6
Medium Priority
?
5,496 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 500 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

Industry Leaders: 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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

771 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