Solved

ASP Unclosed quotes error message

Posted on 2007-03-27
3
212 Views
Last Modified: 2011-10-03
I have an application that people can paste into an input box information from a Word Document.  The data gets posted to a SQL Server database.

However...if the text includes an apostrophe like this line

in one of Boca Raton's finest

Theres an error message.  What can I do to get it to accept the apostrophe?  Error message follows

Incorrect syntax near 's'.
Unclosed quotation mark after the character string ' where txtAdID=4134'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 's'.
Unclosed quotation mark after the character string ' where txtAdID=4134'.

Source Error:


Line 56:         sSQL = sSQL & " where txtAdID=" & Request.QueryString("txtAdID")
Line 57:         oCom2.CommandText = sSQL
Line 58:         oCom2.ExecuteNonQuery()
Line 59:         oCom2.Dispose()

 
0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 37

Expert Comment

by:samtran0331
ID: 18802148
you should always use parameterized queries:
http://aspnet101.com/aspnet101/tutorials.aspx?id=1

doing sql like this:
sSQL = sSQL & " where txtAdID=" & Request.QueryString("txtAdID")

is bad...it leaves you open to sql injection attacks as well as problems like this with the apostrophe
0
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 18802165
here's another article on parameterized queries:
http://www.4guysfromrolla.com/webtech/092601-1.shtml

also, the first page gives you a "quick fix" for your apostrophe problem...but I'd highly recommend that you use parameterized queries and/or stored procedures
0
 

Author Comment

by:lrbrister
ID: 18802357
samtran0331
  This does get executed in a stored procedure.  But thanks for the info and the link
Points being awarded now
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question