ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 5th, 2003, 08:27 PM
Tyssen Tyssen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brisbane
Posts: 129 Tyssen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 55 sec
Reputation Power: 6
Lightbulb Too few parameters. Expected 1.

I'm having a problem with a query on a new table that I've just added to my database.

Here's the query:

<%
productID=Request.Querystring("pID")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("theDB.mdb")
sql = "SELECT * FROM kbs, authors WHERE kbs.author=authors.authorID AND id = " & productID & ";"
set rs = Server.CreateObject("ADODB.Recordset")
set rs = conn.execute(sql)
%>

With this, I get a 'too few parameters' error message, but a nearly identical query gives me exactly what I want. Here's the one that works:

<%
productID=Request.Querystring("pID")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("theDB.mdb")
sql = "SELECT * FROM kbs, media where kbs.media=media.mediaTypeID AND id = " & productID & ";"
set rs = Server.CreateObject("ADODB.Recordset")
set rs = conn.execute(sql)
%>

I've checked the relationships of all 3 tables, and they all look exactly the same, so I can't figure out why the query from kbs-media works, but kbs-authors doesn't. Is there something about table structure I don't know or am missing, or is it something else completely?

Reply With Quote
  #2  
Old October 5th, 2003, 09:12 PM
pda8333 pda8333 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 216 pda8333 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 6
is the field type for kbs.author same as authors.authorID?

Reply With Quote
  #3  
Old October 5th, 2003, 09:51 PM
Tyssen Tyssen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brisbane
Posts: 129 Tyssen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 55 sec
Reputation Power: 6
Quote:
Originally posted by pda8333
is the field type for kbs.author same as authors.authorID?


authors.authorID is autonumber and kbs.author is number.

Reply With Quote
  #4  
Old October 5th, 2003, 09:59 PM
pda8333 pda8333 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 216 pda8333 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 6
well, since both are similar, i can't see any wrong in the field type. Are there any identical records (author = authorid) in kbs & media ?

Reply With Quote
  #5  
Old October 5th, 2003, 10:05 PM
Tyssen Tyssen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brisbane
Posts: 129 Tyssen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 55 sec
Reputation Power: 6
I'm using Access and the kbs table was filled out using look-up wizards on the subject, media and authors fields. The authors, media and subject tables are all identical as are their relationships to kbs, except that authors has one more field than media or subject (they have 2, authors has 3, but that shouldn't make a difference, should it??

Reply With Quote
  #6  
Old October 5th, 2003, 10:22 PM
pda8333 pda8333 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 216 pda8333 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 6
i don't think that shud matter. well, i guess i can't really help you out here. good luck troubleshooting.

Reply With Quote
  #7  
Old October 8th, 2003, 01:12 PM
Tim_Lensen's Avatar
Tim_Lensen Tim_Lensen is offline
Wonder of the world
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: the Netherlands
Posts: 22 Tim_Lensen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Use this in your first line of code

productID=Cint(Request.Querystring("pID") )

Now it should work.
Before this change, it was a string and you handled it like integer.

Reply With Quote
  #8  
Old October 8th, 2003, 04:38 PM
Tyssen Tyssen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brisbane
Posts: 129 Tyssen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 55 sec
Reputation Power: 6
I actually got it to work yesterday using this:

sql = "SELECT * FROM kbs, authors, media WHERE kbs.author=authors.authorID AND id = " & productID & " AND kbs.media=media.mediaTypeID;"

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Too few parameters. Expected 1.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT