Val
Thu Mar 31 19:52:11 CST 2005
Hi,
To avoid this issue you need to pass values as a parameters, not to
concatenate SQL statement. In this case provider will handle single quotes
properly regardless how many of them are in a value(s). It also handles
other special characters
--
Val Mazur
Microsoft MVP
http://xport.mvps.org
"Matthias S." <postamt@_remove_emvoid_remove_.de> wrote in message
news:u4pH$ikNFHA.2252@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> I'd like to INSERT a string into a database using C#. The way I've tried
> it is the following:
>
> sQuery = string.Format("INSERT INTO myTable (Header, Body) VALUES
> ('{0}','{1}')", sHeader, sBody);
>
> It works fine until I have an occurence of ' (an apostrophy) in either the
> string-variables sHeader or sBody. How can I circumvent this?
>
> Thanks in advance!
>
> --
> /Matthias