how can I insert this string into sql??

Posted on 2006-06-19
Last Modified: 2010-04-17
I have problem with quote and double quote :(

qr = "UPDATE Task SET Finished = '<td class='biz'></td><td class='isp'><img /><img src='styles/spunta.gif'></td>' WHERE" +
            "Username+task+CONVERT(VARCHAR(10), tasktime, 103) = '" + e.CommandArgument.ToString() + "'";
        cm = new OleDbCommand(qr, con);
Question by:tatamaruri
LVL 142

Accepted Solution

Guy Hengel [angelIII / a3] earned 500 total points
ID: 16939722
qr = "UPDATE Task SET Finished = '<td class=''biz''></td><td class=''isp''><img /><img src=''styles/spunta.gif''></td>' WHERE" +
            " Username+task+CONVERT(VARCHAR(10), tasktime, 103) = '" + e.CommandArgument.ToString() + "'";

Expert Comment

ID: 16939808
To clarify angelIII answer: replace ' (single quote) with '' (double single quote, not a double quote)

Author Comment

ID: 16939828
can't do like this: qr = "UPDATE Task SET Finished = '<td class=''biz''></td><td class=''isp''><img /><img src=''styles/spunta.gif''></td>' WHERE"

in ASP.NET if you use " ,it mean you finish a string. So that you will get error at "biz"
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

LVL 26

Expert Comment

ID: 16939871
qr = "UPDATE Task SET Finished = '<td class=""biz""></td><td class=""isp""><img /><img src=""styles/spunta.gif""></td>' WHERE" +
            "Username+task+CONVERT(VARCHAR(10), tasktime, 103) = '" + e.CommandArgument.ToString() + "'";

to escape double quotes, use ""

Author Comment

ID: 16939885
To: DireOrbAnt

I did as you said but get error: "; expected" at string ""biz""></td><td class=""isp""><img /><img src=""styles/spunta.gif""></td>' WHERE"

LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16939896
>in ASP.NET if you use " ,it mean you finish a string. So that you will get error at "biz"

please check carefully, i posted ''biz'' which is not the same as "biz": 2 single quotes vs double quotes.

Author Comment

ID: 16939938
Yeah, Thanks.
I did it

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question