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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for a carriage return in a text field

Status
Not open for further replies.

levinll

Programmer
Oct 29, 2001
65
US
Somehow a user was able to enter a CR/LF into a text field in one of my tables. I'd like to be able to search the rest of the records to see if this has happened before, but I'm not sure of the syntax I'd have to use. Can anyone enlighten me ?

Also does anyone have any idea on how to prevent a CR/LF from being inserted into a database ? I'm using VB as a front end/SQL Server as the back end.
 
In T-SQL, CHAR(10) is a new line, CHAR(13) is a carriage return. Maybe
Code:
SELECT * FROM myTable WHERE PATINDEX(CHAR(10), myTextField) > 0

In VB, you might use the String.Replace method to replace these characters with nothing. I don't know VB so this is just an idea.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top