Quotes/Blanks in ASP

Discussion in 'ASP General' started by Shawn, Jan 14, 2004.

  1. Shawn

    Shawn Guest

    I have part of the following SQL statement:

    '*********
    SELECT
    d_service_area.service_area AS ServiceArea,
    d_environment.environment AS Environment,
    d_platform_function.platform_function AS Platform,
    d_hw_type.hw_type AS hdwType,
    d_hardware.standard AS hdwHardware,
    d_hardware.config_vrsn AS hdwVersion,
    d_sw_type.sw_type AS sfwType,
    d_software.standard AS sfwSoftware,
    d_software.config_vrsn AS sfwVersion,
    hw_sw.time_frame 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_function.platform_function AS
    Platform, " & _
    "d_hw_type.hw_type AS hdwType, " & _
    "d_hardware.standard AS hdwHardware, " & _
    "d_hardware.config_vrsn AS hdwVersion, " & _
    "d_sw_type.sw_type AS sfwType, " & _
    "d_software.standard AS sfwSoftware, " & _
    "d_software.config_vrsn AS sfwVersion, " & _
    "hw_sw.time_frame 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 " & _

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

    Thanks in advance for any help!
     
    Shawn, Jan 14, 2004
    #1
    1. Advertising

  2. Shawn

    Ray at Guest

    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" <> wrote in message
    news:0cd401c3dab5$db886270$...
    > I have part of the following SQL statement:
    >
    > '*********
    > SELECT
    > d_service_area.service_area AS ServiceArea,
    > d_environment.environment AS Environment,
    > d_platform_function.platform_function AS Platform,
    > d_hw_type.hw_type AS hdwType,
    > d_hardware.standard AS hdwHardware,
    > d_hardware.config_vrsn AS hdwVersion,
    > d_sw_type.sw_type AS sfwType,
    > d_software.standard AS sfwSoftware,
    > d_software.config_vrsn AS sfwVersion,
    > hw_sw.time_frame 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_function.platform_function AS
    > Platform, " & _
    > "d_hw_type.hw_type AS hdwType, " & _
    > "d_hardware.standard AS hdwHardware, " & _
    > "d_hardware.config_vrsn AS hdwVersion, " & _
    > "d_sw_type.sw_type AS sfwType, " & _
    > "d_software.standard AS sfwSoftware, " & _
    > "d_software.config_vrsn AS sfwVersion, " & _
    > "hw_sw.time_frame 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 " & _
    >
    > *******************
    >
    > Thanks in advance for any help!
     
    Ray at, Jan 14, 2004
    #2
    1. Advertising

  3. Shawn

    Dan Boylett Guest

    "Shawn" <> wrote in message
    news:0cd401c3dab5$db886270$...
    > I know the following isn't correct:
    > ******************
    > "SELECT " & _
    > "d_service_area.service_area AS ServiceArea, " & _
    > "d_environment.environment AS Environment, " & _
    > "d_platform_function.platform_function AS
    > Platform, " & _
    > "d_hw_type.hw_type AS hdwType, " & _
    > "d_hardware.standard AS hdwHardware, " & _
    > "d_hardware.config_vrsn AS hdwVersion, " & _
    > "d_sw_type.sw_type AS sfwType, " & _
    > "d_software.standard AS sfwSoftware, " & _
    > "d_software.config_vrsn AS sfwVersion, " & _
    > "hw_sw.time_frame 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 " & _
    >


    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 " & _
     
    Dan Boylett, Jan 14, 2004
    #3
  4. Shawn

    Bob Barrows Guest

    Shawn wrote:
    > 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?
    >

    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.
     
    Bob Barrows, Jan 14, 2004
    #4
  5. Shawn

    swp Guest

    use single quotes instead of double quotes.

    "Shawn" <> wrote in message news:<0cd401c3dab5$db886270$>...
    > I have part of the following SQL statement:
    >
    > '*********
    > SELECT
    > d_service_area.service_area AS ServiceArea,
    > d_environment.environment AS Environment,
    > d_platform_function.platform_function AS Platform,
    > d_hw_type.hw_type AS hdwType,
    > d_hardware.standard AS hdwHardware,
    > d_hardware.config_vrsn AS hdwVersion,
    > d_sw_type.sw_type AS sfwType,
    > d_software.standard AS sfwSoftware,
    > d_software.config_vrsn AS sfwVersion,
    > hw_sw.time_frame 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_function.platform_function AS
    > Platform, " & _
    > "d_hw_type.hw_type AS hdwType, " & _
    > "d_hardware.standard AS hdwHardware, " & _
    > "d_hardware.config_vrsn AS hdwVersion, " & _
    > "d_sw_type.sw_type AS sfwType, " & _
    > "d_software.standard AS sfwSoftware, " & _
    > "d_software.config_vrsn AS sfwVersion, " & _
    > "hw_sw.time_frame 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 " & _
    >
    > *******************
    >
    > Thanks in advance for any help!
     
    swp, Jan 14, 2004
    #5
  6. Shawn

    swp Guest

    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_allowed_into_this_database"
    password = "some_strong_password_you_set_for_him"

    xsql = "SELECT "
    xsql = xsql & "sa.service_area AS ServiceArea, "
    xsql = xsql & "e.environment AS Environment, "
    xsql = xsql & "pf.platform_function AS Platform, "
    xsql = xsql & "hwt.hw_type AS hdwType, "
    xsql = xsql & "h.standard AS hdwHardware, "
    xsql = xsql & "h.config_vrsn AS hdwVersion, "
    xsql = xsql & "swt.sw_type AS sfwType, "
    xsql = xsql & "s.standard AS sfwSoftware, "
    xsql = xsql & "s.config_vrsn AS sfwVersion, "
    xsql = xsql & "hstime_frame AS tf, "
    xsql = xsql & "hs.impl_plan_start_date AS pStDate, "
    xsql = xsql & "hs.impl_act_start_date AS aStDate, "
    xsql = xsql & "hs.impl_plan_duration 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_environment e, "
    xsql = xsql & "d_platform_function 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.CreateObject("ADODB.Connection")
    xcon.Open db_name, username, password
    set xrs = xcon.execute(xsql)
    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

    (swp) wrote in message news:<>...
    > use single quotes instead of double quotes.
    >
    > "Shawn" <> wrote in message news:<0cd401c3dab5$db886270$>...
    > > I have part of the following SQL statement:
    > >
    > > '*********
    > > SELECT
    > > d_service_area.service_area AS ServiceArea,
    > > d_environment.environment AS Environment,
    > > d_platform_function.platform_function AS Platform,
    > > d_hw_type.hw_type AS hdwType,
    > > d_hardware.standard AS hdwHardware,
    > > d_hardware.config_vrsn AS hdwVersion,
    > > d_sw_type.sw_type AS sfwType,
    > > d_software.standard AS sfwSoftware,
    > > d_software.config_vrsn AS sfwVersion,
    > > hw_sw.time_frame 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_function.platform_function AS
    > > Platform, " & _
    > > "d_hw_type.hw_type AS hdwType, " & _
    > > "d_hardware.standard AS hdwHardware, " & _
    > > "d_hardware.config_vrsn AS hdwVersion, " & _
    > > "d_sw_type.sw_type AS sfwType, " & _
    > > "d_software.standard AS sfwSoftware, " & _
    > > "d_software.config_vrsn AS sfwVersion, " & _
    > > "hw_sw.time_frame 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 " & _
    > >
    > > *******************
    > >
    > > Thanks in advance for any help!
     
    swp, Jan 15, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris White

    Quotes/Double Quotes in Image Control

    Chris White, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,908
    Hermit Dave
    Sep 22, 2004
  2. Chris
    Replies:
    1
    Views:
    13,748
    Oisin
    Mar 24, 2006
  3. Lawrence Tierney

    Multiline quotes - escaping quotes - et al

    Lawrence Tierney, Dec 24, 2003, in forum: Java
    Replies:
    3
    Views:
    4,542
    Andrew Thompson
    Dec 24, 2003
  4. jOhn
    Replies:
    1
    Views:
    267
    Phlip
    Jan 29, 2008
  5. Richard Sandoval
    Replies:
    5
    Views:
    229
    7stud --
    Apr 26, 2011
Loading...

Share This Page