|
Question : Matching case in SQL
|
|
I use visual basic & create my own sql or get it from access wizard
I need to match or not match user input with what is on access db as follows
sql="select * from details where data = '" & txtData.text & "'"
data on the db is "abc" and txtData.text="ABC"
In the above sql I get a match which is not correct
how do I write the sql so I don't get a match?
|
|
Answer : Matching case in SQL
|
|
Paste the following code into a NEW module:
Function fncASCII(strInput As String) As String
' Converts the input string into a PURE ascii value ' Can be used to distinguish the same data value ' which may be in differing "cases" ' e.g. Yale becomes: 089097108101 ' YALE becomes: 089065076069 ' yale becomes: 121097108101
' Useful in GROUPBY clause/s
Dim inti As Integer Dim ascCharacter As Integer For inti = 1 To Len(strInput) ' ascCharacter = Asc(Mid(strInput, intI, 1)) fncASCII = fncASCII & Right("000" & Asc(Mid(strInput, inti, 1)), 3) Next inti
End Function
....
and then include "calls" to that function within your query by altering it thus:
sql = "select * from details where fncASCII(data) = '" & fncASCII(txtData.text) & "'"
|
|
|
|