473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

SQLInCode

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")
Jun 27 '08 #1
2 759
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.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"gh" <gh@att.netwrote in message
news:uj**************@TK2MSFTNGP06.phx.gbl...
>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")

Jun 27 '08 #2
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
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.