469,903 Members | 1,520 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Escape single quote in string

DDE
Hi,

wich way can I escape a string sent to an OleDbComman containing single
quote?

Thanks

Dominique
Nov 15 '05 #1
6 21723
Use an OledbParameter instead and let it take care of it for you.
"DDE" <dd*@iaireinfo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

wich way can I escape a string sent to an OleDbComman containing single
quote?

Thanks

Dominique

Nov 15 '05 #2
Hi,

I think that it depends of the DB engine you are talking to. I would search
on the product documentation first and/or not found I would try escape it
with the same ' , with a " or enclosing the string in [ ]

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"DDE" <dd*@iaireinfo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

wich way can I escape a string sent to an OleDbComman containing single
quote?

Thanks

Dominique

Nov 15 '05 #3
DDE
Hi,

I am not using Parameters in this case, I am just lookin for a method to do
the thing.

Dominique

"William Ryan" <do********@comcast.nospam.net> wrote in message
news:eq**************@tk2msftngp13.phx.gbl...
Use an OledbParameter instead and let it take care of it for you.
"DDE" <dd*@iaireinfo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

wich way can I escape a string sent to an OleDbComman containing single
quote?

Thanks

Dominique


Nov 15 '05 #4
DDE
I am not using a constant string but a structure element.

Dominique
"Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
news:#4**************@TK2MSFTNGP09.phx.gbl...
Hi,

I think that it depends of the DB engine you are talking to. I would search on the product documentation first and/or not found I would try escape it
with the same ' , with a " or enclosing the string in [ ]

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"DDE" <dd*@iaireinfo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

wich way can I escape a string sent to an OleDbComman containing single
quote?

Thanks

Dominique


Nov 15 '05 #5
Typically, if you Do a string.replace and replace the single quote with
double quotes, it will work for most RDBMS systems. This will do it even if
there's no quote present, the replace will just be ignored. I highly
recommend against this type of methodology, but if you are sure this is what
you want to do...

Dim s As String = "O'Brien"

MessageBox.Show(s.Replace("'", "''"))

"DDE" <dd*@iaireinfo.com> wrote in message
news:O3**************@TK2MSFTNGP11.phx.gbl...
Hi,

I am not using Parameters in this case, I am just lookin for a method to do the thing.

Dominique

"William Ryan" <do********@comcast.nospam.net> wrote in message
news:eq**************@tk2msftngp13.phx.gbl...
Use an OledbParameter instead and let it take care of it for you.
"DDE" <dd*@iaireinfo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

wich way can I escape a string sent to an OleDbComman containing single quote?

Thanks

Dominique



Nov 15 '05 #6
Hi,

At the end you will have to assign the query to OleDbCommand.CommandText ,
this is a string property, this is where you can do the substitution I'm
talking about

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"DDE" <dd*@iaireinfo.com> wrote in message
news:Or*************@TK2MSFTNGP11.phx.gbl...
I am not using a constant string but a structure element.

Dominique
"Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
news:#4**************@TK2MSFTNGP09.phx.gbl...
Hi,

I think that it depends of the DB engine you are talking to. I would

search
on the product documentation first and/or not found I would try escape it with the same ' , with a " or enclosing the string in [ ]

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"DDE" <dd*@iaireinfo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

wich way can I escape a string sent to an OleDbComman containing single quote?

Thanks

Dominique



Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Steve Litvack | last post: by
6 posts views Thread by HK guy | last post: by
131 posts views Thread by Lawrence D'Oliveiro | last post: by
8 posts views Thread by Marina Levit [MVP] | last post: by
3 posts views Thread by Tiger Champ | last post: by
1 post views Thread by crybaby | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.