This is a discussion on "using apostrophe in sql statement" within the Classic ASP section. This forum, and the thread "using apostrophe in sql statement are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
using apostrophe in sql statement
|
||
| Notices |
![]() |
|
|
LinkBack (1) | Thread Tools |
|
|||
|
using apostrophe in sql statement
I'm having an error with my ASP page when a person puts an apostrphe into a field to be entered into a sql database.. here is a test on the sql statement:
SELECT * FROM tblRequests WHERE firstname="Test" AND lastname="Test'O" AND checktype="Bankruptcy" AND dateEntered="10/5/2006" here is the code that puts it together:
Microsoft OLE DB Provider for ODBC Drivers error '80040e21' ODBC driver does not support the requested properties. /secur-it/background/submitorder.asp, line 125 can anyone help me out with this? |
|
|
|
|||
|
Re: using apostrophe in sql statement
you need to escape all single quotes with another single quote as bar minimum
So Denis O'Reilly becomes Denis O''Reilly (with two single quotes instead of one single quote). Use a function that does a replace... e.g. Function SQLSafe(strText) SQLSafe = Replace(strText, "'", "''") End Function Then you can put SQLsafe(xxx) around whatever values you link into your SQL query Failing to sanitize scripts like this is more dangerous than you think. Google for SQL injection and prepare to cr4p your pants. |
![]() |
| Tags |
| sql statements |
| Thread Tools | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.webforumz.com/classic-asp/9307-using-apostrophe-in-sql-statement.htm
|
||||
| Posted By | For | Type | Date | |
| Web Design Forums - Web design and development help and discussion | This thread | Refback | Oct 7th, 2006 21:18 | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP If Statement... | mcdanielnc89 | PHP Forum | 16 | Dec 9th, 2007 17:44 |
| How to include font name that has apostrophe | Lchad | PHP Forum | 3 | Sep 17th, 2007 16:30 |
| apostrophe becomes ’ | aaronh | Web Page Design | 12 | Jul 30th, 2007 13:38 |
| Apostrophe in Text Output | RobinDeanDotCom | PHP Forum | 2 | Oct 4th, 2006 12:48 |
| Apostrophe... | Lizard- | Classic ASP | 2 | Aug 13th, 2004 13:11 |