Replace Single Quote with Back Quote MS SQL:
UPDATE TABLE_NAME SET FIELD_NAME = REPLACE(FIELD_NAME, Char(39), Char(96));
C# Scrub Method:
public string Scrub(string sqlString)
{
return sqlString.Replace((char)39, (char)96);
}
C# UnScrub Method (modify accordingly):
public string UnScrub(string sqlString)
{
string finalSqlString = String.Empty;
if (sqlString.Contains("'"))
{
int singleQuoteCount = 0;
for (int index = 0; index < sqlString.Length; index++)
{
if (sqlString[index] == '\'')
{
singleQuoteCount++;
}
else
{
singleQuoteCount = 0;
}
if (singleQuoteCount <= 1)
{
finalSqlString = finalSqlString + sqlString[index];
}
}
}
else
{
finalSqlString = sqlString;
}
finalSqlString = finalSqlString.Replace("'", "''");
return finalSqlString;
}
Friday, January 29, 2010
Subscribe to:
Posts (Atom)
Check This Out!
More Links to Good Information
- December (1)
- October (1)
- January (1)
- September (1)
- February (2)
- January (2)
- May (3)
- February (1)
- May (1)
- October (1)
- January (1)
- August (1)
- March (1)
- May (1)
- March (1)
- January (1)
- March (1)
- December (2)
- September (2)
- June (1)
- February (1)
- January (1)
- October (1)
- December (2)
- November (1)
- August (4)
- July (14)
- June (10)
- May (9)
- April (2)
- February (4)
- January (2)
- December (7)
- October (10)