Re: Handling Strings in SQL server
- From: MrSmersh <MrSmersh@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 29 May 2008 23:02:00 -0700
About injection you are right but the string was 'O' and all this quoted so
was safe...
And are scenarios when stored procedures are a no no for example multi
database targeting.
But if just old plain SQL Server stored procedures is the most common
solution.
"William Vaughn [MVP]" wrote:
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
- References:
- Handling Strings in SQL server
- From: Bhakti via DotNetMonster.com
- Re: Handling Strings in SQL server
- From: William Vaughn [MVP]
- Handling Strings in SQL server
- Prev by Date: Re: transaction scope
- Next by Date: SQLParamter setting.
- Previous by thread: Re: Handling Strings in SQL server
- Next by thread: SQLParamter setting.
- Index(es):
Relevant Pages
|