VB icon

Accent Insensitive database querying

Email
Submitted on: 1/7/2015 8:18:00 PM
By: Karabunga (from psc cd)  
Level: Advanced
User Rating: By 8 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0, VB Script, ASP (Active Server Pages)
Views: 1669
 
     Since MS-Access doesn't support accent insensitive queries by itself (MS SQL Server does as far as I know), I had to create a function that would fix the problem. With this function, it is possible to turn any SQL query into an accent insensitive query. With a few little modifications, it works great with ASP too!
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Accent Insensitive database querying
' Description:Since MS-Access doesn't support accent insensitive queries by itself (MS SQL Server does as far as I know), I had to create a function that would fix the problem. With this function, it is possible to turn any SQL query into an accent insensitive query. With a few little modifications, it works great with ASP too!
' By: Karabunga (from psc cd)
'
' Inputs:Example: STRSQL = "SELECT * FROM MyTable WHERE animal LIKE '%" & AccIns("ELEPHANT") & "%'"
This will return any record where animal = lephant, Elephant, lphant, elphant, etc. You get the picture. Now have fun! :)
'
' Returns:An accent insensitive string to use against a database.
'
' Assumes:You need to know how SQL queries work.
'
' Side Effects:My friend's computer exploded last time he used this function, so watch out!
'**************************************

Function AccIns(Str As String) As String
Dim CurLtr As String * 1
For x = 1 To Len(Str)
CurLtr = Mid(Str, x, 1)
Select Case CurLtr
Case "e", "", "", "", "", "E", "", "", "", ""
AccIns = AccIns & "[eE]"
Case "a", "", "", "", "A", "", "", ""
AccIns = AccIns & "[aA]"
Case "i", "", "", "", "I", "", "", ""
AccIns = AccIns & "[iI]"
Case "o", "", "", "", "O", "", "", ""
AccIns = AccIns & "[oO]"
Case "u", "", "", "", "U", "", "", ""
AccIns = AccIns & "[uU]"
Case "c", "", "C", ""
AccIns = AccIns & "[cC]"
Case Else
AccIns = AccIns & CurLtr
End Select
Next
End Function


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.