Re: Making user input safe
From: CHRISM (chris_at_sorry.no.spam.com)
Date: 11/04/04
- Next message: Ken Dopierala Jr.: "Re: Making user input safe"
- Previous message: rroman_at_800mcmahan.com: "Re: changing the value of a textBox with selection from a dropDown"
- In reply to: Stephen Adam: "Making user input safe"
- Next in thread: Ken Dopierala Jr.: "Re: Making user input safe"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 04 Nov 2004 13:34:27 -0500
On Thu, 04 Nov 2004 17:31:51 GMT, "Stephen Adam"
<stephen.adam@ntlworld.com> wrote:
>Hi there,
>
>I am working on a project were a user can update a SQL Server DB via a web
>form. I've included a number of text boxes for a user to enter in strings.
>The text from these boxes is then used in an update command. My problem is
>if the user enters any speech marks then it will break the code as they are
>interpretted as the end of the SQL statement. I'm sure there are other
>characters which will also cause problems.
>
>Here is a code snippet.
>sSQL = "INSERT INTO t_links VALUES (" & "'" & tbLinkName.Text() & "'" & ","
>& "'" & tbLinkAddress.Text() & "'" & "," & "'" & tbLinkDescription.Text() &
>"'" & ")"
>
>Is there any automated way of turning the contents of these text boxes into
>their literal form so the contents can be safely used in this way?
>
>In PHP you've got HTMLSpecialChars function which will turn script/html into
>the actual text we want. Is there anything like this I can use for VB.net?
>
>Thanks
>
>Steve
You want to change single quotes into two single quotes..
Instead of using:
tbLinkName.Text()
Try using:
tbLinkName.Text().Replace("'","''")
Same for any other text data that may contain single quotes..
// CHRIS
- Next message: Ken Dopierala Jr.: "Re: Making user input safe"
- Previous message: rroman_at_800mcmahan.com: "Re: changing the value of a textBox with selection from a dropDown"
- In reply to: Stephen Adam: "Making user input safe"
- Next in thread: Ken Dopierala Jr.: "Re: Making user input safe"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|