Solved

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

Posted on 2010-08-23
5
343 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
[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
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

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