Question How to detect control characters in database fields

Snowflake

Member
Joined
Sep 16, 2014
Messages
15
Programming Experience
Beginner
What is the best way to detect and remove control characters (TAB,CR,LF) from fields in a database table?
 
They are characters like any other so they can be detected like any other. The specifics will depend on exactly what database you're using and/or exactly where you want to do it, i.e. in the database itself or in a VB.NET application.

EDIT: Actually, I should qualify that any character that doesn't have a literal representation cannot be detected by comparing to a literal representation like other characters would, but they do still have an ASCII or Unicode value so they can be detected by comparing the ASCII or Unicode values of the characters in your text to specific values. Those specific values can be hard-coded by you or, in VB, you can use the appropriate fields of the ControlChars class.
 
Apologies for not getting back sooner,
The database is on SQL Server and connected to my program by ADO.NET
It was probably not the best or the most efficient way of completing the task, but I ended up reading each record individually and running it through a regular expression.

Thank you for your effort.
 
Back
Top