Link to home
Start Free TrialLog in
Avatar of N2012
N2012

asked on

Classic ASP - problem with MS SQL Select Query?

I'm using MS SQL select query in classic ASP which I cannot figure out.

If I query a field by this value
    "LTC DWG # 05-08-1883, BGA50"
I get error 500, but if I remove the space in front of the #,
   "LTC DWG# 05-08-1883, BGA50"
(in the SQL data as well as the query), it works fine.

At first, I thought it was a coding issue involving this string " #", but I can query the following value just fine without any error:
    "LTC DWG # 05-08-1999, BGA48"

I've likely overlooked something very simple. Please help - any pointers appreciated a ton!!!
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

how do you construct your SQL statement in your asp codes?

additional space shouldn't causing you an SQL error, for most it will return record not was found for you.
Avatar of N2012
N2012

ASKER

I build the SQL query like this:

SQLQRY = "SELECT TableName.* FROM TableName WHERE (SearchField LIKE '%" & VALUE & "%')"
SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of N2012

ASKER

url encode?
Not on the server.  That is only for transmissions between computers over HTTP.
Could you please post your complete query ?
Avatar of N2012

ASKER

Problem was a combination of script and encoding. URL Encoding resolved part of the problem, but I also had an issue with the script, after all. Thanks for prompt responses!!!
So do you need more help or you are done?
Avatar of N2012

ASKER

done, thanks!