Saturday, March 31, 2012

text box editing

I have a text box where users can enter a reference number. This can be a varchar. I want to use this in a SQL lookup so I want to check for characters that may cause issues in the SQL statement . / _ % and such and escape them so they can still search by these fields? Any suggestions out there?You can use a regular expression to remove characters you don't want like so:

Dim badCharReplace As Regex = New Regex("([<>""'%;()&])")
Dim s As String = badCharReplace.Replace(psInput, "")

0 comments:

Post a Comment