Solved

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

Posted on 2010-08-23
5
334 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Please explain "Multi-Tenant Services" 5 60
Syntax Error 2 42
ASP.net Javascript use multiple sliders 2 16
Ajax Panel Not Updating When Triggered By Timer 4 36
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

937 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

8 Experts available now in Live!

Get 1:1 Help Now