Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case insensitive in If Statement

Status
Not open for further replies.

Vermontecher

Programmer
Feb 13, 2005
14
US
Hello,
I am sure this is simple for somoen but it is sure giving me a headache today. I want to do the following...

<%
GetState(s_State)
if s_State = "CO" or _
s_state "Colorado" then
Response.write ("CO")
End If
%>

My function is as follows...

function GetState(s_state)
sql = "select * from [order] where order_id=0" & order_id & " and site_id=0" & site_id
set rs = conn.execute(sql)
if not rs.eof then
s_state = lcase(rs("s_state"))
end if
rs.close : set rs = nothing
end function


I have this working fine but the problem is I only get results if the CO or Colorado are case sensitive. I want them to return no matter what the user types in, co, Co, ColOrAdO, anything like that. What am i doing wrong?

Thanks
Vermont Techer
 
Hi,
Where are the users typing in anything? It is not part of your posting..

I am also a little confused by the Sql statement you are constructing ( it looks like you will have something like 'where order_id=0<variableorder_id.value>') - can you post a compelted one ( use Response.Write(sql) after the call to Get State.
)




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Since you're setting s_state to lower case in your function, then testing it with "CO" or "Colorado", both of which have capital letters, you will NEVER get CO written to the screen.

Lee
 
Is it the user data or the database that has case sensitivity problems? If it is the user, convert everything to U/C before checking. If it is the database, extract all records out of the DB, convert them to U/C and write them back. It is a lot easier if you save the data in a consistent form instead of allowing the user to select their own random mix of letters. Another alternative is to use a dropdown list - that way, the user never has to type anything and you know what you are going to get.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top