Unix Technical Forum

Problem with string

This is a discussion on Problem with string within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi My user has put ' with editable place and then press enter so this same way put text ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 03:24 AM
Qwiati
 
Posts: n/a
Default Problem with string

Hi
My user has put ' with editable place and then press enter so this same way
put text information with ' string into database.
When I try tu user command : UPDATE and try to change text with ' and use
command WHERE = ('text'') then I just received error command from SQL2000
server - I know what kind of problem is but i need your hel to get some
diferent command or method to change wrong put information
Thx for your qiuck help
Kayser


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 03:24 AM
Steven Wilmot
 
Posts: n/a
Default Re: Problem with string


"Qwiati" <qwiati@wp.pl> wrote in message news:c51ncc$it$1@news.onet.pl...
> Hi
> My user has put ' with editable place and then press enter so this same

way
> put text information with ' string into database.
> When I try tu user command : UPDATE and try to change text with ' and use
> command WHERE = ('text'') then I just received error command from SQL2000
> server - I know what kind of problem is but i need your hel to get some
> diferent command or method to change wrong put information
> Thx for your qiuck help
> Kayser
>


Replace any occurrence of {quote} in your string with {quote}{quote}.

e.g.

update mytable set field = ' doesn''t ... ' where field = 'does not'

S



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 03:24 AM
Qwiati
 
Posts: n/a
Default Re: Problem with string


"Steven Wilmot" <steven-news@wilmot.me.uk> wrote in message
news:40747454$0$63629$5a6aecb4@news.aaisp.net.uk.. .
>
> "Qwiati" <qwiati@wp.pl> wrote in message news:c51ncc$it$1@news.onet.pl...
> > Hi
> > My user has put ' with editable place and then press enter so this same

> way
> > put text information with ' string into database.
> > When I try tu user command : UPDATE and try to change text with ' and

use
> > command WHERE = ('text'') then I just received error command from

SQL2000
> > server - I know what kind of problem is but i need your hel to get some
> > diferent command or method to change wrong put information
> > Thx for your qiuck help
> > Kayser
> >

>
> Replace any occurrence of {quote} in your string with {quote}{quote}.
>
> e.g.
>
> update mytable set field = ' doesn''t ... ' where field = 'does not'
>

hmmm but let me show you what I have:
update mytable set field = 'blabla' where field = 'blabla" - this is my
problem because of the end of text I have in database have this --> ' <--
so if I set command: where filed = 'blabla" then I have .......syntax error

Or I dont undersood waht you would like to tell me


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 03:25 AM
Jay Allard
 
Posts: n/a
Default Re: Problem with string

Maybe you should use a stored procedure or parameters instead of
building the string manually. Then you don't have to worry about the '
issue, and you don't have to worry about a sql injection attack.

instead of

sSQL = "update table set column='" + sSomeVariable + "' where x='" +
sSomeValue + "'"

do

sSQL = "update table set column=@sValue where x=@sKey"

Then, if it's a command object in ado or ado.net, add parameters to
your command object containing the values.

Personally, I prefer to put the update in the stored procedure then
pass parameters to the stored procedure.

But, if you want to do it the string way...

sSQL = "update table set column='" + replace(sSomeVariable, "'", "''")
+ "' where x='" + replace(sSomeValue, "'", "''") + "'"

Assuming vb/asp there. .net would be sSomeVariable.Replace("'", "''")




"Qwiati" <qwiati@wp.pl> wrote in message news:<c520ci$obs$1@news.onet.pl>...
> "Steven Wilmot" <steven-news@wilmot.me.uk> wrote in message
> news:40747454$0$63629$5a6aecb4@news.aaisp.net.uk.. .
> >
> > "Qwiati" <qwiati@wp.pl> wrote in message news:c51ncc$it$1@news.onet.pl...
> > > Hi
> > > My user has put ' with editable place and then press enter so this same

> way
> > > put text information with ' string into database.
> > > When I try tu user command : UPDATE and try to change text with ' and

> use
> > > command WHERE = ('text'') then I just received error command from

> SQL2000
> > > server - I know what kind of problem is but i need your hel to get some
> > > diferent command or method to change wrong put information
> > > Thx for your qiuck help
> > > Kayser
> > >

> >
> > Replace any occurrence of {quote} in your string with {quote}{quote}.
> >
> > e.g.
> >
> > update mytable set field = ' doesn''t ... ' where field = 'does not'
> >

> hmmm but let me show you what I have:
> update mytable set field = 'blabla' where field = 'blabla" - this is my
> problem because of the end of text I have in database have this --> ' <--
> so if I set command: where filed = 'blabla" then I have .......syntax error
>
> Or I dont undersood waht you would like to tell me

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-29-2008, 03:26 AM
Qwiati
 
Posts: n/a
Default Re: Problem with string

Thx for your help guys it helps when I put double '''' at the and of command
:
update mytable set 'blabla' where field = 'blabla'''' - so the solution was
very easy
anyway thx for your help once more
Regards
Q


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:31 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com