PDA

View Full Version : ASP Session Variable Doesn't work


Joannatang
July 29th, 2004, 10:20 AM
Hi all

Hope you can help me on something! In total, I've created two pages. The first page shows the results from the search of various patients using the variable (id) i.e. 's' displays all patients with surnames beginning with s). From this page, I've created a session variable (nm). The second page shows further details of that particular surname once the surname is clicked from the first page. The nm session variable will enable the user to the first page from the second page.

However, in the SQL query from the first page, I put in 'or'(see below), the session variable works but doesn't search the surnames according to what the user wants.

SELECT Patient.PatientID, Title.Title, Patient.Forenames, Patient.Surname
FROM Title INNER JOIN Patient ON Title.TitleID = Patient.TitleID
WHERE Patient.Surname LIKE 'id%' or 'nm'

But if I type in 'and', the session variable doesn't work and the searching surnames work.

SELECT Patient.PatientID, Title.Title, Patient.Forenames, Patient.Surname
FROM Title INNER JOIN Patient ON Title.TitleID = Patient.TitleID
WHERE Patient.Surname LIKE 'id%' and 'nm'

Does anyone know the solution to this problem? Thanks. :wave:

Steven.Bentley
July 29th, 2004, 05:40 PM
I'm never done any ASP but if this were a PHP script I would temporarily echo/print the value of the variable that you want to know whether it has a value just before the query. If you get the value you want then it's the SQL that's at fault, which is what I suspect here...

WHERE Patient.Surname LIKE 'id%' and 'nm'

should that not be

WHERE Patient.Surname LIKE 'id%' and <name of some column> = 'nm'