Solved

asp.net passing cml param to SQL with a ' that breaks the proc

Posted on 2010-08-23
5
329 Views
Last Modified: 2012-05-10
so i have an asp.net c# web app that generates an xml string using string builder that concatenates a bunch of text boxes and drop downs into an xml parameter and passes it to SQL proc.

everything was going well until someone entered "eat at joe's" and the single quote broke the stored proc...

whast the best way to manage this?

0
Comment
Question by:realcoding
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:David Robitaille
ID: 33503723
double the quote!
I use string.replace("'", "'')
this replace ' with ' '
0
 
LVL 18

Accepted Solution

by:
David Robitaille earned 300 total points
ID: 33503744
sorry, it`s
string.replace("'", "''")
the last " was missing
 
0
 
LVL 35

Expert Comment

by:YZlat
ID: 33503749
single quote needs to be replaced by two single quotes
0
 
LVL 35

Expert Comment

by:YZlat
ID: 33503757
davrob60 got it:)
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 200 total points
ID: 33503901
If it's XML then you would be better off converting it to '
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now