Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

SQLInCode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gh - 29 May 2008 20:19 GMT
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")
Teemu Keiski - 29 May 2008 20:27 GMT
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.

Signature

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

>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.
[quoted text clipped - 4 lines]
> ("SELECT  A.ADDR1||'' ''||A.CITY||'', '' " +
>  "||STATE.ABBRV||''  ''||A.POSTALCODE AS CSZ")
Hans Kesting - 30 May 2008 11:35 GMT
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
[quoted text clipped - 4 lines]
> ("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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.