ASP Database queries from multiple selections in forms (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


Guest -> ASP Database queries from multiple selections in forms (3/9/2001 18:09:00)

Hi,

I am new to web programming, and to your forum. But, I keep coming back here for answers to questions, so I thought it was time to post my own.

I am trying to pass the results from a multiple selection form to a fp_sQry= "SELECT..." query in an *.asp page. If the parameter coming in is numeric, my code works fine. If the parameter coming in is text, I can't get it to work.

Here's the query:

strQry = " SELECT *
" FROM Air_Obs " & _
" WHERE ((Air_Obs.Site_ID IN (::Site_ID: " & _
" AND (Air_Obs.Parameter_ID IN ('::Parameter_ID::') " & _
" AND (Air_Obs.Obs_Date BETWEEN #::StartDate::# AND #::EndDate::#))"

Site_ID IN (::Site_ID: is numeric and works like a charm. However, Parameter_ID is being sent as a comma delineated string without the single quotes around the text (BSO4, Si, Cl). I think the query wants it to be ('BSO4', 'Si', 'Cl'). How do you get this relatively simple query to work properly? It will work if I only make one selection, and when I hard code some values into the query (obviously not what I need!).

Any help would be greatly appreciated. My head is sore from banging it against my monitor...

Monica





Spooky -> RE: ASP Database queries from multiple selections in forms (3/9/2001 22:14:00)

The trick here is to remember that the return from a comma delimited form looks like :
BSO4, Si, Cl
and not :
'BSO4', 'Si', 'Cl'

So youll have to be tricky and make sure your form fields are given values of

'BSO4' 'Si' and 'Cl' etc

Now your query looks like :

(Air_Obs.Parameter_ID IN (::Parameter_ID:

Make sense?!

------------------
Spooky
"I am Spooky of Borg. Prepare to be assimilated, babycakes!"
Subscribe to OutFront News
Database / DRW Q & A
The Spooky Login!





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
4.614258E-02