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

SQL Escape in C# 2

Status
Not open for further replies.

kurie

Programmer
Jun 4, 2008
170
ZA
Can anyone please help with a function that will accept a string as a parameter and will replace all occurrences of the “’” (apostrophe\single quote) character with the valid SQL equivalent i.e. escape the single quote to be used in a SQL statement. And then return the correctly formatted string.

Regards
 
use parameterized queries instead of sql injection.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
What jmeckley said...

myString = myString.Replace("[!]'[/!]", "[!]''[/!]")

Lodlaiden

You've got questions and source code. We want both!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top