Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 03-12-2007, 10:39 PM Too Few Perameters
Novice Talker

Posts: 12
Trades: 0
Hi all.

EDIT: Sorry for the spelling error in the thread title. I must be showing off my wonderful typing skills.


Its been awhile since I was here last. I am having a problem with a simple statment to call records from a MS Access database. I get the error:


Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. /pages/general_page/default.asp, line 14

(line 14 is gonna be this line: Rs.Open sql, Conn )


I have looked this error up on MS, and they seem to think that one of my database columns don't match. I have checked, doublechecked, and triplechecked, and this is not the case. Any ideas?

Code:
 
<% 
Dim Conn
Dim Rs
Dim sql
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/pathtomydatabase/database.mdb")
sql= "SELECT * FROM custompages WHERE 'custompageurl'="& Request.QueryString("custompageurl") &"" 
Rs.Open sql, Conn 
%>
 
<% Response.Write ("<h3>" & Rs("title") & "</h3>") %>
<% Response.Write ("<p>" & Rs("content") & "</p>") %>
<% Rs.MoveNext %>
<%
Loop 
Rs.Close
Set Rs = Nothing
Set Conn = Nothing
%>
Thanks.

Last edited by MIDNIGHTBANDIT9; 03-12-2007 at 10:41 PM..
MIDNIGHTBANDIT9 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-13-2007, 04:23 AM Re: Too Few Perameters
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
try;

sql= "SELECT * FROM custompages WHERE 'custompageurl' = '"& Request.QueryString("custompageurl") &"' ;"

two debug checks;
response.write out the value of sql to see if it is what you would expect response.write the value of the querystring to ensure that it has a value and/or test for a value before calling the routine.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-13-2007, 05:24 PM Re: Too Few Perameters
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Follow Hirst's advice. In particular, Response.Write(some debug info here) is an invaluable tool. Since you can't debug old school ASP code, this is the best tool in our box for figuring out what went wrong.

When MS Access throws the "Too few paremeters - expected x" error, it means that it doesn't understand something in your query, and has decided to make that a parameter. Which is a pretty good guess on its part, but not always right. For example ( and try this with me ), if you set up a query that says "SELECT * FROM custompages WHERE custompageurl = someURL" and then execute the query, before it actually runs, it will give you a dialog box asking for a value for someURL. Then it will run the query using that value. Only, dialog boxes don't work on the web, so instead it throws an error if there's a parameter it doesn't have a value for. If you drop in your query string, it's going to see it as an unknown field, and assume it's a parameter.

Next, I think there's a mistake in your SQL and carried over into Chris's example. If custompageurl is a field in your talbe, you don't want single quotes ( ' ) around it.
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 03-22-2007, 08:36 PM Re: Too Few Perameters
Novice Talker

Posts: 12
Trades: 0
Sorry for taking so long to get back. I was on vacation.


sql= "SELECT * FROM custompages WHERE 'custompageurl' = '"& Request.QueryString("custompageurl") &"' ;" worked perfectly

Thank you all.
MIDNIGHTBANDIT9 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Too Few Perameters
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20376 seconds with 12 queries