SQL & ASP Where problem

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

gbrandwood

Thread Starter
Joined
Jan 4, 2000
Messages
137
Dear all

I have the following code in my ASP page:

Set objCon=Server.CreateObject("ADODB.Connection")
objCon.Open "hrpolicies"
Set recCon=Server.CreateObject("ADODB.Recordset")
SQL=SQL + "SELECT DISTINCT Category"
SQL=SQL + " FROM tblPolicies"
SQL=SQL + " WHERE Category != 'NONE'"
SQL=SQL + " ORDER BY Category DESC;"
recCon.Open SQL,objCon,3

I want the page to return distinct records from the category field, from the table called tblPolicies, but only where the category field is not set to NONE. E.g. if the category field is set to HR, it will list HR. NONE is a value a user will have typed in. It is not null.

If I change my code so that it says show records where the category fields does contain the word NONE, i.e.:

Set objCon=Server.CreateObject("ADODB.Connection")
objCon.Open "hrpolicies"
Set recCon=Server.CreateObject("ADODB.Recordset")
SQL=SQL + "SELECT DISTINCT Category"
SQL=SQL + " FROM tblPolicies"
SQL=SQL + " WHERE Category = 'NONE'"
SQL=SQL + " ORDER BY Category DESC;"
recCon.Open SQL,objCon,3

The page works fine. So I'm confused as to where am I going wrong?

Any help would be appreciated.

Regards

Gareth
 

gbrandwood

Thread Starter
Joined
Jan 4, 2000
Messages
137
Opps! After spending ages wondering what was up my code - I realised that changing my where statement from:

SQL=SQL + " WHERE Category != 'NONE'"

to:

SQL=SQL + " WHERE Category <> 'NONE'"

did the trick!

Sorry to have bothered all you nice people.

Regards

Gareth
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Top