Print Page | Close Window

Error: Too few Parameters

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=623
Printed Date: 28 March 2026 at 9:09am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Error: Too few Parameters
Posted By: zaboss
Subject: Error: Too few Parameters
Date Posted: 01 March 2003 at 5:16am

I got this error Too few parameters. expected 3 from the folowwing query:

Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("../../db/articles.mdb")
        sql = "Select * FROM Articles Where Art_Section.Articles = " & RS1("Art_Section") & " AND Issue_Nr=" & RS0("Cur_Issue") & ""
        set rs2 = MyConn.Execute(Sql)

Both RS1 and RS0 are triggered correctly. When ggogle it, I found that this error is caused by "empty fields in the db", which is not the case.

Basicaly, this rs 2 should find in the db all records where simultaneously Art_Section = some value AND Issue Nr = another value.



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web



Replies:
Posted By: zaboss
Date Posted: 01 March 2003 at 10:39am
Well, it seems that indeed it does not find any records, although it should. It triggers the corect criteria (both values of the RS1 and, respectively, RS0, are correct), but it does not find the records in the db, although there are several records.

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: michael
Date Posted: 01 March 2003 at 11:00am
Did you try to just print the sql statement instead of executing it? Does it fill in the rs0 and rs1 values. I don't think I ever did it that way, overlapping the recordsets. Why don't you put the value of theses recordsets in a variable and if there is more then one result put them in an array.


Posted By: zaboss
Date Posted: 01 March 2003 at 12:50pm

Yes, it fills in rs0 and rs1 correctly. I have tryed to put rs0 in a varriable, but to no avail. rs1 triggers at least 2 data - there are only 2 sections filled in in the db.

The problem is that it seems not to find anything in the db corresponding to critirias, although there are several.



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: michael
Date Posted: 01 March 2003 at 1:19pm
What is the part: .....& RS0("Cur_Issue") & ""  here in red for?? You should be able to omit that.


Posted By: zaboss
Date Posted: 01 March 2003 at 1:38pm

I did. Here is the modified sql:

   sql = '"Select * FROM Articles Where Art_Section.Articles = " & RS1("Art_Section") & "' AND Issue_Nr=" & RS0("Cur_Issue")

Now it needs only 1 parameter. If I cut off the part after AND, it works. But I realy need to sort the records by the Issue_Nr...

The code is the front page preview of an article manager I make for a monthly magazine. It should display on a front page the Title of the article, the author and the caption with a link towards the rest of article. Everything is Ok, but I have this problem. As there will be more issues, I need to display on the front page only the current issue's articles, as the rest of them should be in the archive.



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: zaboss
Date Posted: 02 March 2003 at 6:43am

Thought of posting the whole code:

<%
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("../../db/cadranpolitic.mdb")
  set rs0 = MyConn.Execute ("Select Cur_Issue From Cur_Issue")
  session("cur_issue")=rs0("cur_issue")
  set rs1 = MyConn.Execute ("Select Distinct Art_Section From Articles")
  if not rs1.EOF then
 rs1.movefirst
 do
Response.Write("<H2>" & RS1("Art_Section") & "</H2>")
Response.Write("<hr>")
  set rs2 = MyConn.Execute ("Select * From Articles Where Art_Section='" & RS1("Art_Section") &"' AND Issue_Nr="& session("cur_issue") & "")
  if not rs2.EOF then
   rs2.movefirst
   do
Response.Write("<H3>" & RS2("Art_Title") & "</H3>" & "</br>")
Response.Write("<i>"&"<b>" & RS2("Art_Author") & "</b>"&"</i>" &"</br>")
Response.Write(" "& RS2("Art_Header") &"" &  "<a href=""view_article.asp?item=" & RS2("ID") &"""target=""_blank"">Articol complet...</a>"& "</br>")
Response.Write("<hr>")
    rs2.MoveNext
  loop until rs2.EOF
  end if
   response.write "</br>"
  rs1.movenext
 loop until rs1.EOF
end if
 MyConn.Close
set dbConn = Nothing
set rs1 = Nothing
set rs2 = Nothing
%>

Whell there are 2 problems with it: 1 If I try to sort records by issue_nr, it triggers the "to few parameters Error.Expect 1". If comment that, the script works but instead o response.writing the records the way I want - and it should, i guess as I select distinct them. That is, instead of:
Art_Section_1
Art_Section_1_Article_1_Title
Art_Section_1_Article_1_Author
Art_Section_1_Article_1_Header

Art_Section_1_Article_2_Title
Art_Section_1_Article_2_Author
Art_Section_1_Article_2_Header...

Art_Section_2
Art_Section_2_Article_1_Title
Art_Section_2_Article_1_Author
Art_Section_2_Article_1_Header...

It displays them totaly random...



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: michael
Date Posted: 02 March 2003 at 10:56am

OK taking that both fields you are having are numeric values:
sql = '"Select * FROM Articles Where Art_Section.Articles = " & CInt(RS1("Art_Section")) & "' AND Issue_Nr=" & CInt(RS0("Cur_Issue"))

should work though I did not go through your whole code yet, try that first and let me know....



Posted By: zaboss
Date Posted: 02 March 2003 at 11:47am
Well, no, they are both text fields.

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: michael
Date Posted: 02 March 2003 at 12:20pm

Well then they both need to be in single quotes like:

sql = "Select * FROM Articles Where Art_Section.Articles = '" & RS1("Art_Section") & "' AND Issue_Nr='" & RS0("Cur_Issue") & "'"



Posted By: zaboss
Date Posted: 02 March 2003 at 12:32pm
Nope! The same error! Too few Parameters. Expected 1. Even puted in session variable still trigers the error. I realy don't get it!

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: michael
Date Posted: 02 March 2003 at 1:15pm

Well there is some bug in your code that I just might be overlooking but the way you do it is just odd. Now, instead of executing the query do a resoponse.write sql   and post the result here.



Posted By: zaboss
Date Posted: 02 March 2003 at 1:32pm
When Response.Write, the error is: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: michael
Date Posted: 02 March 2003 at 2:35pm
huh? I want you to just write the variable sql right before you execute it. Comment the execute statement out......  if there is something else bugging your script do an 'On Error Resume Next' on top of the page.


Posted By: Bunce
Date Posted: 02 March 2003 at 4:55pm
RESPONSE.WRITE(sql)
RESPONSE.END


-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: zaboss
Date Posted: 03 March 2003 at 3:59am
This is exactly what I did (response.write(sql)) and the error I got was "Arguments Are of Wrong Type...." I ggogle it and found a pretty detaliated explanation of the error, but I'm afraid it's a lilltle bit over my head!

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: Bunce
Date Posted: 03 March 2003 at 4:08am

If you put:

RESPONSE.WRITE(sql)
RESPONSE.END

before you execute the sql, you will NOT get an error, as you are stopping the code (response.end) before it gets to the database. The sql string will be printed on the page, and you can then see exactly what *would* be sent to the database.



-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: zaboss
Date Posted: 03 March 2003 at 4:28am

I see. Anyway, I sort it out. One of the googled pages have something similar to me. it seems that there were a conflict between items (don't ask me what may cause it , but I'm sure you guys would get it when you see the solution).

So, the solution is:

 set rs2 = MyConn.Execute ("Select * From Articles Where Art_Section='" & RS1("Art_Section") &"'ORDER BY FP_Position ASC")
  rs2.Filter = "Isue_Nr='"& session("cur_issue") &"'"

I f you can see what was wrong, please tell me ! From what I understand it seems that you can not trigger a record set and filter it in the same "sentence".



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net