SQLInCode

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gh

    SQLInCode

    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.POSTALCOD E AS CSZ")
  • Teemu Keiski

    #2
    Re: SQLInCode

    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



    "gh" <gh@att.netwrot e in message
    news:uj7pvDcwIH A.3860@TK2MSFTN GP06.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.POSTALCOD E AS CSZ")

    Comment

    • Hans Kesting

      #3
      Re: SQLInCode

      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.POSTALCOD E 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


      Comment

      Working...