This topic is locked
[SOLVED]

 strWhereClause

11/2/2011 7:25:50 AM
ASPRunnerPro General questions
P
Philip author

I try to select the records on a LIST page with an event (List page: Before SQL query).

I have an Access db.
When I do this for a field type long integer, the following code works:

strWhereClause = whereAdd(strWhereClause,"NUMBERfield=" & Session("NUMBERfield"))


When I try to do similar for a text field I end up with an "internal error":

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


Has anyone an idea what is wrong with the code / syntax?
Thanks - Philip

Sergey Kornilov admin 11/2/2011

Syntax looks correct. Try to print the whole SQL Query on the page to see what might be wrong.

P
Philip author 11/2/2011



Syntax looks correct. Try to print the whole SQL Query on the page to see what might be wrong.


I just printed the SQL Query. Unfortunately that only works for the correct SQL statement; the wrong one isn't printed because of the internal error message.

Or is there another possibility to print it besides appsetings.asp / dDebug = true ?
Philip

Sergey Kornilov admin 11/2/2011

Make sure you print it before error happens.
You can also add Response.End line after Response.Write to make sure it always printed.

P
Philip author 11/2/2011



Make sure you print it before error happens.
You can also add Response.End line after Response.Write to make sure it always printed.


Many thanks for this quick response.

But sorry - can't follow you and need a more detailed instruction where / how to do this.
Philip

Sergey Kornilov admin 11/2/2011

Where and how you trying to print this SQL Query right now?

P
Philip author 11/2/2011



Where and how you trying to print this SQL Query right now?


I just set in appsetings.asp / dDebug = true.

Sergey Kornilov admin 11/2/2011

You need to print SQL Query and WHERE clause in BeforeSQLQuery event using Response.Write statements.
Since you having an issue with WHERE clause try to print it after assigning a value to it.

P
Philip author 11/2/2011

Sergey,

Many thanks for your help. I reinvestigated my code and found the problem:

in Query Designer I added a table to the table with my LIST page. Unfortunately both tables are using the same fildnames :-(
I just had to change my code

from

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


to

strWhereClause = whereAdd(strWhereClause,"TABELname.TEXTfield='" & Session("TEXTfield") & "'")


Thanks again,

Philip