How to escape forward slash?
Posted
by AndrewB
on Stack Overflow
See other posts from Stack Overflow
or by AndrewB
Published on 2010-04-30T12:21:41Z
Indexed on
2010/04/30
12:27 UTC
Read the original article
Hit count: 735
c#
|sql-server-2008
I have the following sql command through code and because the parameter contains a forward slash when I evaluate the sql row after the update the column is just empty.
sqlCommand.CommandText = String.Format("update {0} set {1}='{2}'where id = @Id",
tableName, ColumnName, forwardSlashText);
sqlCommand.Parameters.Add("@Id", SqlDbType.UniqueIdentifier).Value = rowId;
numRowsAffected = sqlCommand.ExecuteNonQuery();
adding a log.debug to this command i get the following output...
update my_table_name set mime_type='application/pdf' where id = @Id
So i would assume that the command is correct, but then looking at the row the mime_type column is empty.
© Stack Overflow or respective owner