Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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 information …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 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