1 Replies - 617 Views - Last Post: 29 October 2012 - 08:51 PM Rate Topic: -----

#1 robgw3  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 138
  • Joined: 23-February 12

How do you convert symbols to enter them safely into a database?

Posted 29 October 2012 - 03:41 PM

I am having trouble finding the answer to this online, could someone explain to me how i would convert the contents of a textbox so that any symbols that a user types in like <, >, /, ", ", %, &, etc would be converted into a safe form to put into a database? And of course taken back out and converted into the same thing they went in as.

For example if someone typed into a textbox <Hi> then it would enter it into the database as &lt;Hi&gt; or something like that, whatever would be safe to go into the database.

[Oh right i forgot, asp.net using vb rather than C# or whatever it is]

[Never mind, i just used a regular expression to prevent the user from even using those symbols. Not quite what was suggested for the assignment but it works.]

This post has been edited by robgw3: 29 October 2012 - 05:43 PM


Is This A Good Question/Topic? 0
  • +

Replies To: How do you convert symbols to enter them safely into a database?

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 445
  • View blog
  • Posts: 1,501
  • Joined: 28-April 09

Re: How do you convert symbols to enter them safely into a database?

Posted 29 October 2012 - 08:51 PM

You could look into Server.HtmlEncode and Server.HtmlDecode
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1