SQLInCode

G

gh

I was using the SQL in another program I had. When I try to use it in
the C# it will not work. The ASP.NET compiler does not like the single
quotes. Is there another way to do this with SQL?

Thanks


("SELECT A.ADDR1||'' ''||A.CITY||'', '' " +
"||STATE.ABBRV||'' ''||A.POSTALCODE AS CSZ")
 
T

Teemu Keiski

Quotes work if you escape them properly with \' or precede the string with
@ when you'd need to double the quotes as escape sequences would not be
processed.

But can't you use a stored query in Access or stored procedure in SQL Server
database, if you are using either of them? Inline SQL is bit awkward to
maintain.
 
H

Hans Kesting

gh submitted this idea :
I was using the SQL in another program I had. When I try to use it in the C#
it will not work. The ASP.NET compiler does not like the single quotes. Is
there another way to do this with SQL?

Thanks


("SELECT A.ADDR1||'' ''||A.CITY||'', '' " +
"||STATE.ABBRV||'' ''||A.POSTALCODE AS CSZ")

string theSql = "SELECT A.ADDR1||' '||A.CITY||', ' " +
"||STATE.ABBRV||' '||A.POSTALCODE AS CSZ";

should compile fine. You don't need to double (or escape) the single
quotes inside the string, as they have no special meaning for a C#
string.

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,173
Messages
2,570,938
Members
47,475
Latest member
NovellaSce

Latest Threads

Top