PDA

Click to See Complete Forum and Search --> : ASP Database


Hutty
Jul 13th, 2000, 09:12 AM
On my request form is a listbox that is filled with names from a database. The recordset that I want to retrieve is in the corresponding query.asp file. When i submit the request i can an error "too few parameters. Expected 1". Here is the code that generates this error. The last line (set rstemp)is the cause of the error. Any help is appreciated.

Dim Listboxid
Listboxid = Request.Form("MyListBox")
' ASP program that displays a database in table form
myDSN="DSN=db1"
mySQL="select name, account, qtr1 from act_1 where name = " & Listboxid & " and account = 'ret_prem_g' and qtr1 > 0"
showblank=" "
shownull="-null-"

set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)

Serge
Jul 13th, 2000, 09:54 AM
Usually, when you get this kind of error, it means that you either misspelled the field name in your SQL statement or the field name your used is not in the table. Check your SQL statement again to verify that the field names are spelled correctly.

Hutty
Jul 13th, 2000, 02:05 PM
Actually, the problem is in the SQL statement where I reference the name selected in the listbox on the request form. Not sure how to reference this object. I need the correct syntax for referencing the listbox (MyListBox) on the request form. Thanks

capone
Jul 13th, 2000, 02:37 PM
Put single quotes in the query around the variable.
...1 where name = '" & Listboxid & "' and account...

Hutty
Jul 13th, 2000, 02:43 PM
Thanks Capone, it works! i tried it earlier, but may have had them twisted. thanks.

capone
Jul 13th, 2000, 05:12 PM
np