This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > March 2005 > ASP Help with recordset queries!!





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author ASP Help with recordset queries!!
longsdale

2005-03-29, 11:50 pm

Hi,
I have been trying to construct a results page in dreamweaver/asp if i put a
search in with one parameter it works fine (ie, select name from names where
name = 'MMcolPara') where MMcolPara is equal to Request.Form("Name"). BUT when
i add more boxes to my form and go to my results page and add new parameters
like varProductName which is equal to Request.Form("ProductName") and add it to
the sql query (ie, select name from names where name = 'MMcolPara' and/or
ProductName = 'varProductName') i get errors, why???
I'm trying to return either both results or just one result depending on the
info sent. I realise i must have to set up if... else.. clauses???
Any help in this matter?
Thanks, Ian

Greg Scheeler

2005-03-29, 11:52 pm

i'd suggest changing your query so that instead of '=', you use a 'like'
comparison so that you can use the wildcard '%'.. that way, you can change
your code so that if the user doesn't select a value from the form, you can
assign a '%' value to that comparison. then that portion of the 'where'
clause will return all records. in effect, ignoring that comparison.


--
Greg Scheeler
email: gpswebdesigns @ yahoo.com
"longsdale" <webforumsuser@macromedia.com> wrote in message
news:d2c1fi$d04$1@forums.macromedia.com...
> Hi,
> I have been trying to construct a results page in dreamweaver/asp if i put
> a
> search in with one parameter it works fine (ie, select name from names
> where
> name = 'MMcolPara') where MMcolPara is equal to Request.Form("Name"). BUT
> when
> i add more boxes to my form and go to my results page and add new
> parameters
> like varProductName which is equal to Request.Form("ProductName") and add
> it to
> the sql query (ie, select name from names where name = 'MMcolPara' and/or
> ProductName = 'varProductName') i get errors, why???
> I'm trying to return either both results or just one result depending on
> the
> info sent. I realise i must have to set up if... else.. clauses???
> Any help in this matter?
> Thanks, Ian
>



Baxter

2005-03-29, 11:54 pm

If your using Name as a field name in the database it is a reserved word and
can't be used ProductName is fine and UserName and So on.
A simple Select would be
Select ProductName UserName Rest Of Fields
From Your Database Table
WHERE ProductName LIKE '%varProductName%' And UsereName LIKE '%varUserName%'
and so on
Vriables
ProductName % Request.("ProDuctName")

Hope this helps.
Dave

"longsdale" <webforumsuser@macromedia.com> wrote in message
news:d2c1fi$d04$1@forums.macromedia.com...
> Hi,
> I have been trying to construct a results page in dreamweaver/asp if i

put a
> search in with one parameter it works fine (ie, select name from names

where
> name = 'MMcolPara') where MMcolPara is equal to Request.Form("Name"). BUT

when
> i add more boxes to my form and go to my results page and add new

parameters
> like varProductName which is equal to Request.Form("ProductName") and add

it to
> the sql query (ie, select name from names where name = 'MMcolPara' and/or
> ProductName = 'varProductName') i get errors, why???
> I'm trying to return either both results or just one result depending on

the
> info sent. I realise i must have to set up if... else.. clauses???
> Any help in this matter?
> Thanks, Ian
>



longsdale

2005-03-30, 6:48 pm

Hi,
Thanks that's working fine... just one more thing. I tried to set up a
show region when recordset is empty but it doesn't seem to be working? Can you
tell a different way to do this or re-iterate the procedure so that if no
record is entered or wrong data is enetered a message will show???
Many Thanks, Ian

longsdale

2005-03-31, 6:22 pm

Any takers on this one... to return a simple error when recordset is empty? Hasn't worked for me yet.
Ian
Les Matthews

2005-03-31, 6:31 pm

How are you applying the Show Region behavior? Can you post the code?

"longsdale" <webforumsuser@macromedia.com> wrote in message
news:d2egck$3gb$1@forums.macromedia.com...
> Hi,
> Thanks that's working fine... just one more thing. I tried to set up a
> show region when recordset is empty but it doesn't seem to be working? Can
> you
> tell a different way to do this or re-iterate the procedure so that if no
> record is entered or wrong data is enetered a message will show???
> Many Thanks, Ian
>



Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews