|
 |
access_asp thread: dynamically select column
Message #1 by jake williamson 28 <jake.williamson@2...> on Thu, 18 Apr 2002 11:54:55 +0100
|
|
hi!
i'm trying to get a record set to dynamically select column. for example:
SELECT DISTINCT COUNTY FROM STOCKISTS
WHERE variable-here = True
ORDER BY COUNTY ASC
'variable-here' is passed along a url string and is definable as 'mnuRange'.
the column names are the same as the range names and have check box's in.
so for example if the user clicks 'Mountain' the sql would read:
SELECT DISTINCT COUNTY FROM STOCKISTS
WHERE Mountain = True
ORDER BY COUNTY ASC
so far i've tried these in place of 'variable-here':
' " & Request("mnuRange") & " '
(' " & Request("mnuRange") & " ')
(Request("mnuRange"))
none of which work! i get all the county's!
any ideas oh gurus???
cheers,
jake
Message #2 by lingasamyk@h... on Thu, 18 Apr 2002 12:25:22
|
|
Hi
Check for value carried by Request("mnuRange") using response.write
statement
Response.write Request("mnuRange")
if it carries the correct data then try the following
if the data is passed in the url use the following
sqlqry = " SELECT DISTINCT COUNTY FROM STOCKISTS "
sqlqry = sqlqry + " WHERE " + Request.QueryString("mnuRange") + "= True "
sqlqry = sqlqry + " ORDER BY COUNTY ASC "
if the data is passed by post method use the following
sqlqry = " SELECT DISTINCT COUNTY FROM STOCKISTS "
sqlqry = sqlqry + " WHERE " + Request.Form("mnuRange") + "= True "
sqlqry = sqlqry + " ORDER BY COUNTY ASC "
And the problem is due to the single quote that you used in the
statement ' " & Request("mnuRange") & " '
Regards,
Lingasamy K
>
hi!
i'm trying to get a record set to dynamically select column. for example:
SELECT DISTINCT COUNTY FROM STOCKISTS
WHERE variable-here = True
ORDER BY COUNTY ASC
'variable-here' is passed along a url string and is definable
as 'mnuRange'.
the column names are the same as the range names and have check box's in.
so for example if the user clicks 'Mountain' the sql would read:
SELECT DISTINCT COUNTY FROM STOCKISTS
WHERE Mountain = True
ORDER BY COUNTY ASC
so far i've tried these in place of 'variable-here':
' " & Request("mnuRange") & " '
(' " & Request("mnuRange") & " ')
(Request("mnuRange"))
none of which work! i get all the county's!
any ideas oh gurus???
cheers,
jake
Message #3 by jake williamson 28 <jake.williamson@2...> on Thu, 18 Apr 2002 12:35:23 +0100
|
|
wicked! got it in one!
SELECT DISTINCT COUNTY
FROM TEST WHERE " + Request.QueryString("mnuRange") + " = True
ORDER BY COUNTY ASC
changed the sql to this and hey presto! all good.
thanks for the help, be lost with out you lot!
cheers,
jake
on 18/4/02 12:25, lingasamyk@h... at lingasamyk@h... wrote:
> Hi
>
> Check for value carried by Request("mnuRange") using response.write
> statement
>
> Response.write Request("mnuRange")
>
> if it carries the correct data then try the following
>
> if the data is passed in the url use the following
>
> sqlqry = " SELECT DISTINCT COUNTY FROM STOCKISTS "
> sqlqry = sqlqry + " WHERE " + Request.QueryString("mnuRange") + "= True "
> sqlqry = sqlqry + " ORDER BY COUNTY ASC "
>
> if the data is passed by post method use the following
>
> sqlqry = " SELECT DISTINCT COUNTY FROM STOCKISTS "
> sqlqry = sqlqry + " WHERE " + Request.Form("mnuRange") + "= True "
> sqlqry = sqlqry + " ORDER BY COUNTY ASC "
>
> And the problem is due to the single quote that you used in the
> statement ' " & Request("mnuRange") & " '
>
>
> Regards,
> Lingasamy K
>
>>
> hi!
>
> i'm trying to get a record set to dynamically select column. for example:
>
> SELECT DISTINCT COUNTY FROM STOCKISTS
> WHERE variable-here = True
> ORDER BY COUNTY ASC
>
> 'variable-here' is passed along a url string and is definable
> as 'mnuRange'.
> the column names are the same as the range names and have check box's in.
>
> so for example if the user clicks 'Mountain' the sql would read:
>
> SELECT DISTINCT COUNTY FROM STOCKISTS
> WHERE Mountain = True
> ORDER BY COUNTY ASC
>
> so far i've tried these in place of 'variable-here':
>
> ' " & Request("mnuRange") & " '
>
> (' " & Request("mnuRange") & " ')
>
> (Request("mnuRange"))
>
> none of which work! i get all the county's!
>
> any ideas oh gurus???
>
> cheers,
>
> jake
|
|
 |