Solved

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

Posted on 2006-06-16
6
5,467 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
  • 2
6 Comments
 
LVL 95

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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/…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now