This topic is locked

Passing a param via URL for SQL Where clause

9/24/2008 4:42:28 PM
ASPRunnerPro General questions
S
sfkjeld author

Need to call my ASP runner project from foreign application. Want to pass the DepartmentCode so everyone accessing the project only sees their own Department records.
This is how imagine it to work. Could pass it the query string
http://ShowDepartmentRecords_list.asp?Depa...ntCode=Medicine
or in a Form Object. How do you pass a var and how do I alter the SQL WHERE clause?
I have seen a few posts that refer to "SQL query in the List page. Before SQL query event on the Events tab". I cannot find this. The only event I see is under
Table Events|List Page
But under that, there is nothing about a SQL query event.
Can't wait for help!
Thanks
I am using ASPRunnerPro ver 4.0 build 98

Sergey Kornilov admin 9/24/2008

This event didn't exist in ASPRunnerPro 4.0. Consider upgrading.
In later versions of ASPRunnerPro you can use the following code in BeforeSQL event:

strWhereClause = whereAdd(strWhereClause, "DeparmentCode = '" & Request("DeparmentCode") & "'")
S
sfkjeld author 2/4/2009

This event didn't exist in ASPRunnerPro 4.0. Consider upgrading.

In later versions of ASPRunnerPro you can use the following code in BeforeSQL event:

strWhereClause = whereAdd(strWhereClause, "DeparmentCode = '" & Request("DeparmentCode") & "'")



Well, it took me a while to get around to it, but I finally upgraded. I found the Table Events|List Page|BeforeSQL event. I added the code into the "Custom Code" section. I tried passing the "?DepartmentCode = '" & Request("DeparmentCode") & "'"). No go. What am I missing?
Thanks

J
Jane 2/5/2009

Hi,
here is a sample URL:

http://showdepartmentrecords_list.asp?Depa...ntCode=Medicine
and here is a sample event code:

if Request("DeparmentCode")<>"" then

strWhereClause = whereAdd(strWhereClause, "FieldName = '" & Request("DeparmentCode") & "'")

end if



where FieldName is your actual field name.
If it doesn't help please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

S
sfkjeld author 2/19/2009

I am still not having any luck with this. I even tried to hard code the param I wanted to pass and it still doesn't work.
This is what I am using in the Table Events|List Page|Before Display, I have this code entered into the Sub BeforeShowList(xt,templatefile)
'** Custom code ****

' put your custom code here

strWhereClause = whereAdd(strWhereClause, "RefProviderCHNnum = '001040'")
I would expect this to filter by RefProviderCHNnum. It still shows all records.
Am I putting it in the wrong event?
I can't post the project, since it resides on our intranet.
Appreciate any help you can provide.

Hi,

here is a sample URL:

http://showdepartmentrecords_list.asp?Depa...ntCode=Medicine
and here is a sample event code:
where FieldName is your actual field name.
If it doesn't help please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

S
sfkjeld author 2/19/2009

Wups, just found a prob. When I pass the param to limit/filter the recordset, it works fine. But as soon as a Edit a record, the limit/filter is lost when it returns to the List page. I'd the filter to remain in effect for the entire session.

Sorry, after I posted this, I tested all the List Page events and found the correct one. It is working fine.

Please disregard.
'** Custom code ****

' put your custom code here

strWhereClause = whereAdd(strWhereClause, "RefProviderCHNnum = '001040'")
I would expect this to filter by RefProviderCHNnum. It still shows all records.
Am I putting it in the wrong event?
I can't post the project, since it resides on our intranet.
Appreciate any help you can provide.

S
sfkjeld author 2/19/2009

I don't like it, but I am now passing the filtering through the Search controls. It works, but of course, a user can easily change the Search criteria and is then seeing records they should not.

Wups, just found a prob. When I pass the param to limit/filter the recordset, it works fine. But as soon as a Edit a record, the limit/filter is lost when it returns to the List page. I'd the filter to remain in effect for the entire session.

J
Jane 2/20/2009

Hi,
to filter records on the page useList page: Before SQL query event:

strWhereClause = whereAdd(strWhereClause, "RefProviderCHNnum = '001040'")

S
sfkjeld author 2/20/2009

Hi,

to filter records on the page useList page: Before SQL query event:


??I need to pass the RefProviderCHNnum from another application in the query string. I can't hardcode the '001040' in the strWhereClause. The prob is that when I pass the RefProviderCHNnum in the query string, it only works once. Any subsequent calls while in the ASP Runner pages to the ListView, the RefProviderCHNnum is lost.

Sergey Kornilov admin 2/20/2009

Save it in Session variable.
In BeforeSQLQuery event you can use the following:

if Request("RefProviderCHNnum")<>"" then

Session("RefProviderCHNnum") = Request("RefProviderCHNnum")

end if
if Session("RefProviderCHNnum")<>"" then

strWhereClause = whereAdd(strWhereClause, "RefProviderCHNnum = '" & Session("RefProviderCHNnum") & "'")

end if
S
sfkjeld author 2/23/2009

Save it in Session variable.

In BeforeSQLQuery event you can use the following:

if Request("RefProviderCHNnum")<>"" then

Session("RefProviderCHNnum") = Request("RefProviderCHNnum")

end if
if Session("RefProviderCHNnum")<>"" then

strWhereClause = whereAdd(strWhereClause, "RefProviderCHNnum = '" & Session("RefProviderCHNnum") & "'")

end if


Excellent, that worked!! Thanks.