rlgines
Posts: 3
|
| Posted: 05/31/2007, 4:42 PM |
|
I am writing what I thought was a simple modification to the WHERE clause in CCS, but it is not being used in the query. Here is the code (mostly debug stuff) that I have placed in the BeforeExecuteSelect code.
Function PlantStatus_DataSource_BeforeExecuteSelect() 'PlantStatus_DataSource_BeforeExecuteSelect @2-ADF27D8F
'Custom Code @87-73254650
' -------------------------
' Write your own code here.
response.write "SQL: " & PlantStatus.datasource.SQL & "<br>"
response.write "ORDER BY: " & PlantStatus.datasource.Order & "<br>"
response.write "WHERE: " & PlantStatus.datasource.Where & "<br>"
If session("UserID") = "STL" Then
PlantStatus.datasource.Where = "SiteCode = '" & request.QueryString("SiteCode") & "'"
response.write "WHERE(STL): " & PlantStatus.datasource.Where & "<br>"
Else
PlantStatus.datasource.Where = "SiteCode = '" & session("UserID") & "'"
response.write "WHERE(OTHER): " & PlantStatus.datasource.Where & "<br>"
End If
response.write "QueryString: " & request.QueryString("SiteCode") & "<br>"
response.write "Session(UID): " & session("UserID") & "<br>"
' -------------------------
'End Custom Code
End Function 'Close PlantStatus_DataSource_BeforeExecuteSelect @2-54C34B28
When using a URL of ./PlantStatu_maint.asp?SiteCode=GSC and the logged on user of 'FLG', the query should be forced to choose the record for FLG based on the WHERE clause. It is not. Here is the result that I am getting on the page from the response.write's that I have put in the code.
SQL: SELECT * FROM PlantStatus
ORDER BY:
WHERE: SiteCode = 'GSC'
WHERE(OTHER): SiteCode = 'FLG'
QueryString: GSC
Session(UID): FLG
As you can see, my IF-THEN-ELSE statement is firing correctly,
the PlantStatus.datasource.Where variable is being updated correctly,
however query in this case is being executed with the GSC value instead of the FLG value.
I am assuming that there is something incredibly simple that I am missing here. Any assistance from a second set of eyes would be greatly appreciated.
Thanks a bunch.
|
 |
 |
smalloy
Posts: 107
|
| Posted: 06/07/2007, 2:42 PM |
|
I believe I faced this very issue, to fix it I used the BeforeBuildSelect rather than BeforeExecuteSelect. I know, sounds like it should work in execute but I am betting than moving it to build it will solve your problem.
Steve
_________________
Anything can be done, just give me time and money. |
 |
 |
rlgines
Posts: 3
|
| Posted: 06/07/2007, 3:28 PM |
|
Thanks Steve.
I ended up working with support. It turns out that you are correct. You have to use BeforeBuildSelect. I also found out that if you do what you think is a "Change" to the WHERE clause in BeforeExecuteSelect ... it actually adds the statement to the already existing WHERE clause. The documentation and the forum comments I had researched did not make any of that clear to me. Hopefully this post will help someone else from spinning their wheels as long as I did on this relatively simple item.
Ron
|
 |
 |
mberkeley
Posts: 1
|
| Posted: 07/20/2007, 4:40 AM |
|
Thanks guys,
Your advise has just given me back my weekend 
it works when it is "Before Build Select" (remember to remove your existing "where" clause, because it adds to it!)
Thanks again
Mike
|
 |
 |
AQUANANU
Posts: 107
|
| Posted: 02/19/2008, 7:34 AM |
|
can anyone help!!!!!!!!
I am trying to replace something in the where clause of a grid, i need to do this as it is dependant on the parameters being rcvd.
The where clause isnt getting modified by any means.
I tried moving the following code from beforeselect to beforeexecuteselect to beforebuildselect events but none helped me change the where clause for the recordset being displayed
**************************************
if not isempty(entitiessearch.s_info.value) then
entities.DataSource.Where = replace(entities.DataSource.Where," or entitygroup.type1 is null","")
end if
**************************************
Can anyone tell where to place the code to modify the where clause effectively.
I m using CCS 3.2.0.4 with VB ASP and Ms Access
_________________
Navneet Kakkar
CEO
Positive Thinker's Inc. |
 |
 |
|