Quotes/Blanks in ASP

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

    Quotes/Blanks in ASP

    I have part of the following SQL statement:

    '*********
    SELECT
    d_service_area. service_area AS ServiceArea,
    d_environment.e nvironment AS Environment,
    d_platform_func tion.platform_f unction AS Platform,
    d_hw_type.hw_ty pe AS hdwType,
    d_hardware.stan dard AS hdwHardware,
    d_hardware.conf ig_vrsn AS hdwVersion,
    d_sw_type.sw_ty pe AS sfwType,
    d_software.stan dard AS sfwSoftware,
    d_software.conf ig_vrsn AS sfwVersion,
    hw_sw.time_fram e AS tf,
    hw_sw.impl_plan _start_date AS pStDate,
    hw_sw.impl_act_ start_date AS aStDate,
    hw_sw.impl_plan _duration AS pDur,
    0 AS cmtTyp,
    0 AS cmtSeq,
    " " AS cmt
    '************** ****
    I need to embed this into my ASP page so that I can make
    calls to my DB, but the last line, " " AS cmt , is
    throwing me for a loop. How do I handle this?

    I know the following isn't correct:
    *************** ***
    "SELECT " & _
    "d_service_area .service_area AS ServiceArea, " & _
    "d_environment. environment AS Environment, " & _
    "d_platform_fun ction.platform_ function AS
    Platform, " & _
    "d_hw_type.hw_t ype AS hdwType, " & _
    "d_hardware.sta ndard AS hdwHardware, " & _
    "d_hardware.con fig_vrsn AS hdwVersion, " & _
    "d_sw_type.sw_t ype AS sfwType, " & _
    "d_software.sta ndard AS sfwSoftware, " & _
    "d_software.con fig_vrsn AS sfwVersion, " & _
    "hw_sw.time_fra me AS tf, " & _
    "hw_sw.impl_pla n_start_date AS pStDate, " & _
    "hw_sw.impl_act _start_date AS aStDate, " & _
    "hw_sw.impl_pla n_duration AS pDur, " & _
    "0 AS cmtTyp, " & _
    "0 AS cmtSeq, " & _
    "" "AS cmt " & _

    *************** ****

    Thanks in advance for any help!
  • Ray at

    #2
    Re: Quotes/Blanks in ASP

    Use ' instead of " in SQL. Also, you have an erroneous "& _" at the end of
    your statement.

    When you do need to include " in a string, you double it. Like, "He said,
    ""Hi. How are you?"""

    Ray at work

    "Shawn" <anonymous@disc ussions.microso ft.com> wrote in message
    news:0cd401c3da b5$db886270$a40 1280a@phx.gbl.. .[color=blue]
    > I have part of the following SQL statement:
    >
    > '*********
    > SELECT
    > d_service_area. service_area AS ServiceArea,
    > d_environment.e nvironment AS Environment,
    > d_platform_func tion.platform_f unction AS Platform,
    > d_hw_type.hw_ty pe AS hdwType,
    > d_hardware.stan dard AS hdwHardware,
    > d_hardware.conf ig_vrsn AS hdwVersion,
    > d_sw_type.sw_ty pe AS sfwType,
    > d_software.stan dard AS sfwSoftware,
    > d_software.conf ig_vrsn AS sfwVersion,
    > hw_sw.time_fram e AS tf,
    > hw_sw.impl_plan _start_date AS pStDate,
    > hw_sw.impl_act_ start_date AS aStDate,
    > hw_sw.impl_plan _duration AS pDur,
    > 0 AS cmtTyp,
    > 0 AS cmtSeq,
    > " " AS cmt
    > '************** ****
    > I need to embed this into my ASP page so that I can make
    > calls to my DB, but the last line, " " AS cmt , is
    > throwing me for a loop. How do I handle this?
    >
    > I know the following isn't correct:
    > *************** ***
    > "SELECT " & _
    > "d_service_area .service_area AS ServiceArea, " & _
    > "d_environment. environment AS Environment, " & _
    > "d_platform_fun ction.platform_ function AS
    > Platform, " & _
    > "d_hw_type.hw_t ype AS hdwType, " & _
    > "d_hardware.sta ndard AS hdwHardware, " & _
    > "d_hardware.con fig_vrsn AS hdwVersion, " & _
    > "d_sw_type.sw_t ype AS sfwType, " & _
    > "d_software.sta ndard AS sfwSoftware, " & _
    > "d_software.con fig_vrsn AS sfwVersion, " & _
    > "hw_sw.time_fra me AS tf, " & _
    > "hw_sw.impl_pla n_start_date AS pStDate, " & _
    > "hw_sw.impl_act _start_date AS aStDate, " & _
    > "hw_sw.impl_pla n_duration AS pDur, " & _
    > "0 AS cmtTyp, " & _
    > "0 AS cmtSeq, " & _
    > "" "AS cmt " & _
    >
    > *************** ****
    >
    > Thanks in advance for any help![/color]


    Comment

    • Dan Boylett

      #3
      Re: Quotes/Blanks in ASP


      "Shawn" <anonymous@disc ussions.microso ft.com> wrote in message
      news:0cd401c3da b5$db886270$a40 1280a@phx.gbl.. .[color=blue]
      > I know the following isn't correct:
      > *************** ***
      > "SELECT " & _
      > "d_service_area .service_area AS ServiceArea, " & _
      > "d_environment. environment AS Environment, " & _
      > "d_platform_fun ction.platform_ function AS
      > Platform, " & _
      > "d_hw_type.hw_t ype AS hdwType, " & _
      > "d_hardware.sta ndard AS hdwHardware, " & _
      > "d_hardware.con fig_vrsn AS hdwVersion, " & _
      > "d_sw_type.sw_t ype AS sfwType, " & _
      > "d_software.sta ndard AS sfwSoftware, " & _
      > "d_software.con fig_vrsn AS sfwVersion, " & _
      > "hw_sw.time_fra me AS tf, " & _
      > "hw_sw.impl_pla n_start_date AS pStDate, " & _
      > "hw_sw.impl_act _start_date AS aStDate, " & _
      > "hw_sw.impl_pla n_duration AS pDur, " & _
      > "0 AS cmtTyp, " & _
      > "0 AS cmtSeq, " & _
      > "" "AS cmt " & _
      >[/color]

      Try :

      "0 AS cmtSeq, " & _
      """ ""AS cmt " & _

      Though you may find if you're running anything > then SQL 6.5 that you
      should rather use single qoutes... so :

      "0 AS cmtSeq, " & _
      "' 'AS cmt " & _


      Comment

      • Bob Barrows

        #4
        Re: Quotes/Blanks in ASP

        Shawn wrote:[color=blue]
        > I have part of the following SQL statement:
        >
        > '*********
        > SELECT
        > " " AS cmt
        > '************** ****
        > I need to embed this into my ASP page so that I can make
        > calls to my DB, but the last line, " " AS cmt , is
        > throwing me for a loop. How do I handle this?
        >[/color]
        Two options:
        1. Use single-quotes (') instead of double quotes. Most databases recognize
        this"
        strSQL = "Select ..., ' ' As cmt ... "

        2. If your database does not recognize single quotes as delimiters, escape
        your double-quotes by doubling them:
        strSQL = "Select ..., "" "" As cmt ... "

        HTH,
        Bob Barrows

        --
        Microsoft MVP -- ASP/ASP.NET
        Please reply to the newsgroup. The email account listed in my From
        header is my spam trap, so I don't check it very often. You will get a
        quicker response by posting to the newsgroup.


        Comment

        • swp

          #5
          Re: Quotes/Blanks in ASP

          use single quotes instead of double quotes.

          "Shawn" <anonymous@disc ussions.microso ft.com> wrote in message news:<0cd401c3d ab5$db886270$a4 01280a@phx.gbl> ...[color=blue]
          > I have part of the following SQL statement:
          >
          > '*********
          > SELECT
          > d_service_area. service_area AS ServiceArea,
          > d_environment.e nvironment AS Environment,
          > d_platform_func tion.platform_f unction AS Platform,
          > d_hw_type.hw_ty pe AS hdwType,
          > d_hardware.stan dard AS hdwHardware,
          > d_hardware.conf ig_vrsn AS hdwVersion,
          > d_sw_type.sw_ty pe AS sfwType,
          > d_software.stan dard AS sfwSoftware,
          > d_software.conf ig_vrsn AS sfwVersion,
          > hw_sw.time_fram e AS tf,
          > hw_sw.impl_plan _start_date AS pStDate,
          > hw_sw.impl_act_ start_date AS aStDate,
          > hw_sw.impl_plan _duration AS pDur,
          > 0 AS cmtTyp,
          > 0 AS cmtSeq,
          > " " AS cmt
          > '************** ****
          > I need to embed this into my ASP page so that I can make
          > calls to my DB, but the last line, " " AS cmt , is
          > throwing me for a loop. How do I handle this?
          >
          > I know the following isn't correct:
          > *************** ***
          > "SELECT " & _
          > "d_service_area .service_area AS ServiceArea, " & _
          > "d_environment. environment AS Environment, " & _
          > "d_platform_fun ction.platform_ function AS
          > Platform, " & _
          > "d_hw_type.hw_t ype AS hdwType, " & _
          > "d_hardware.sta ndard AS hdwHardware, " & _
          > "d_hardware.con fig_vrsn AS hdwVersion, " & _
          > "d_sw_type.sw_t ype AS sfwType, " & _
          > "d_software.sta ndard AS sfwSoftware, " & _
          > "d_software.con fig_vrsn AS sfwVersion, " & _
          > "hw_sw.time_fra me AS tf, " & _
          > "hw_sw.impl_pla n_start_date AS pStDate, " & _
          > "hw_sw.impl_act _start_date AS aStDate, " & _
          > "hw_sw.impl_pla n_duration AS pDur, " & _
          > "0 AS cmtTyp, " & _
          > "0 AS cmtSeq, " & _
          > "" "AS cmt " & _
          >
          > *************** ****
          >
          > Thanks in advance for any help![/color]

          Comment

          • swp

            #6
            Re: Quotes/Blanks in ASP

            a little more complete answer (total time to type, including these
            notes: 15 minutes)

            no optimization on the SQL - use INNER JOINs and whatever relations
            you have set up already instead of the clunky FROM clause below. I
            did use table alias names to cut it down a bit and make it more
            readable.

            no optimization on building the SQL string - you may want to do other
            things with the FROM, WHERE, GROUP BY and ORDER BY clauses.

            =============== =============== =======
            DIM xsql, xrs, xcon
            DIM db_name, username, password

            db_name = "SystemDSN_you_ set_up_in_Data_ Sources(ODBC)"
            username = "someone_allowe d_into_this_dat abase"
            password = "some_strong_pa ssword_you_set_ for_him"

            xsql = "SELECT "
            xsql = xsql & "sa.service_are a AS ServiceArea, "
            xsql = xsql & "e.environm ent AS Environment, "
            xsql = xsql & "pf.platform_fu nction AS Platform, "
            xsql = xsql & "hwt.hw_typ e AS hdwType, "
            xsql = xsql & "h.standard AS hdwHardware, "
            xsql = xsql & "h.config_v rsn AS hdwVersion, "
            xsql = xsql & "swt.sw_typ e AS sfwType, "
            xsql = xsql & "s.standard AS sfwSoftware, "
            xsql = xsql & "s.config_v rsn AS sfwVersion, "
            xsql = xsql & "hstime_fra me AS tf, "
            xsql = xsql & "hs.impl_plan_s tart_date AS pStDate, "
            xsql = xsql & "hs.impl_act_st art_date AS aStDate, "
            xsql = xsql & "hs.impl_plan_d uration AS pDur, "
            xsql = xsql & "0 AS cmtTyp, "
            xsql = xsql & "0 AS cmtSeq, "
            xsql = xsql & "' ' AS cmt "
            xsql = xsql & "FROM "
            xsql = xsql & "d_service_ area sa, "
            xsql = xsql & "d_environm ent e, "
            xsql = xsql & "d_platform_fun ction pf, "
            xsql = xsql & "d_hw_type hwt, "
            xsql = xsql & "d_hardware h, "
            xsql = xsql & "d_sw_type swt, "
            xsql = xsql & "d_software s, "
            xsql = xsql & "hw_sw hs "
            xsql = xsql & "WHERE blah blah blah "
            xsql = xsql & "ORDER BY bitty boppity boo "

            set xcon = server.CreateOb ject("ADODB.Con nection")
            xcon.Open db_name, username, password
            set xrs = xcon.execute(xs ql)
            if (not xrs.eof and not xrs.bof) then ' we got records back
            ' do stuff with your recordset called xrs
            else
            ' error message or whatever you do with no data returned
            end if
            set xrs = nothing
            xcon.close
            set xcon = nothing

            =============== =============== =======

            swp

            DSAsteve@aol.co m (swp) wrote in message news:<a59bd1d2. 0401141239.37e9 01c7@posting.go ogle.com>...[color=blue]
            > use single quotes instead of double quotes.
            >
            > "Shawn" <anonymous@disc ussions.microso ft.com> wrote in message news:<0cd401c3d ab5$db886270$a4 01280a@phx.gbl> ...[color=green]
            > > I have part of the following SQL statement:
            > >
            > > '*********
            > > SELECT
            > > d_service_area. service_area AS ServiceArea,
            > > d_environment.e nvironment AS Environment,
            > > d_platform_func tion.platform_f unction AS Platform,
            > > d_hw_type.hw_ty pe AS hdwType,
            > > d_hardware.stan dard AS hdwHardware,
            > > d_hardware.conf ig_vrsn AS hdwVersion,
            > > d_sw_type.sw_ty pe AS sfwType,
            > > d_software.stan dard AS sfwSoftware,
            > > d_software.conf ig_vrsn AS sfwVersion,
            > > hw_sw.time_fram e AS tf,
            > > hw_sw.impl_plan _start_date AS pStDate,
            > > hw_sw.impl_act_ start_date AS aStDate,
            > > hw_sw.impl_plan _duration AS pDur,
            > > 0 AS cmtTyp,
            > > 0 AS cmtSeq,
            > > " " AS cmt
            > > '************** ****
            > > I need to embed this into my ASP page so that I can make
            > > calls to my DB, but the last line, " " AS cmt , is
            > > throwing me for a loop. How do I handle this?
            > >
            > > I know the following isn't correct:
            > > *************** ***
            > > "SELECT " & _
            > > "d_service_area .service_area AS ServiceArea, " & _
            > > "d_environment. environment AS Environment, " & _
            > > "d_platform_fun ction.platform_ function AS
            > > Platform, " & _
            > > "d_hw_type.hw_t ype AS hdwType, " & _
            > > "d_hardware.sta ndard AS hdwHardware, " & _
            > > "d_hardware.con fig_vrsn AS hdwVersion, " & _
            > > "d_sw_type.sw_t ype AS sfwType, " & _
            > > "d_software.sta ndard AS sfwSoftware, " & _
            > > "d_software.con fig_vrsn AS sfwVersion, " & _
            > > "hw_sw.time_fra me AS tf, " & _
            > > "hw_sw.impl_pla n_start_date AS pStDate, " & _
            > > "hw_sw.impl_act _start_date AS aStDate, " & _
            > > "hw_sw.impl_pla n_duration AS pDur, " & _
            > > "0 AS cmtTyp, " & _
            > > "0 AS cmtSeq, " & _
            > > "" "AS cmt " & _
            > >
            > > *************** ****
            > >
            > > Thanks in advance for any help![/color][/color]

            Comment

            Working...