How to escape especial charters like < > in sql query?

74 views Asked by At

the description should look like - Aircraft Configuration function in the <TypeCode> field. but it's displaying in DB as it is but when checked in UI by retrieving it's displaying like ---"Aircraft Configuration function in the field." here the <typecode> converted into HTML in UI screen.

what other ways I have tried are:

update tblApplicationParam 
    set fldValueDescription = 'Aircraft Configuration function in the /<TypeCode/> field'

still it didn't fix my problem.

when parameter retrieved in UI screen the description should show up like this --Aircraft Configuration function in the <TypeCode> field.

1

There are 1 answers

1
x0n On

encode < as &lt; and > as &gt; -- you could either do it in your code with your chosen language's preferred HTML escaping method, or you could do it in SQL, but this means you'd have to update the SQL every time you encountered a symbol that has special meaning in HTML. You should prefer to use a HTML escaping function in your code.