Re: Handling Strings in SQL server
- From: "William Vaughn [MVP]" <billvaNoSPAM@xxxxxxxxx>
- Date: Thu, 29 May 2008 12:30:03 -0700
Ah, no. There are several issues here. First, if your application has problems with the "O'Malley" issue (imbedded single quotes in strings), you need to address the problem at the root. While it's possible to simply pass two single quotes (O''Malley) this does not address the real problem. Consider than if your code permits users to enter strings with embedded single quotes, they can also introduce SQL injection attacks.
A real solution is to pass your string arguments to your SQL queries in ADO or ADO.NET Parameter objects. The data providers know how to frame strings so that imbedded single quotes are not an issue. This approach also deals with a number of other issues--including SQL injection.
hth
--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
"MrSmersh" <MrSmersh@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:4E558D94-CD4D-44FC-A920-FBF9E3CF6448@xxxxxxxxxxxxxxxx
Your problem is the ', try \'. ' is the SQL string "enclosure" so you need to.
escape it.
"Bhakti via DotNetMonster.com" wrote:
how to pass a string having delimitors in sql server cause it is give an
error while saving.
for ge. Name="'D'Malo'"
for this string it is giving an error.
how to resolve this.
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-ado-net/200805/1
- Follow-Ups:
- Re: Handling Strings in SQL server
- From: MrSmersh
- Re: Handling Strings in SQL server
- References:
- Handling Strings in SQL server
- From: Bhakti via DotNetMonster.com
- Handling Strings in SQL server
- Prev by Date: Re: Does Windows Include the Jet OLE DB provider?
- Next by Date: Re: LINQ in Enterprise Library
- Previous by thread: Handling Strings in SQL server
- Next by thread: Re: Handling Strings in SQL server
- Index(es):
Relevant Pages
|