C
Chris Capel
In manually creating SQL queries, it would be nice to have a Framework
function that makes input strings safe to add in a manner like this:
myDescription = MethodToMakeStringQuerySafe(myDescription);
new SqlCommand(
String.Format("INSERT INTO Descriptions (Description) VALUES '{0}'",
myDescription)
).ExecuteNonQuery(); //yes, I know this isn't very good
Is there any such thing? Or must I be relegated to doing something like
myDescription = myDescription.Replace("'", "\\'").Replace(etc);
Another thing. I would think that escaping the single quotes in the input
string would be all that's necessary to make the string safe. Is this
correct?
Chris
function that makes input strings safe to add in a manner like this:
myDescription = MethodToMakeStringQuerySafe(myDescription);
new SqlCommand(
String.Format("INSERT INTO Descriptions (Description) VALUES '{0}'",
myDescription)
).ExecuteNonQuery(); //yes, I know this isn't very good
Is there any such thing? Or must I be relegated to doing something like
myDescription = myDescription.Replace("'", "\\'").Replace(etc);
Another thing. I would think that escaping the single quotes in the input
string would be all that's necessary to make the string safe. Is this
correct?
Chris