Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Error: Too few Parameters
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Error: Too few Parameters

 Post Reply Post Reply Page  123>
Author
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Topic: Error: Too few Parameters
    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
Soft 4 web
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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
Soft 4 web
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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
Soft 4 web
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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
Soft 4 web
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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
Soft 4 web
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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....

Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.