Escaping in VBScript

Discussion in 'ASP General' started by bobbyballgame, Jul 3, 2003.

  1. I am having a problem calling Stored Procedures:

    ....
    dim MyValue, MyOtherValue

    MyValue = "Bobby's value"
    MyOtherValue = Bobby's other value"

    rs.Open "exec MyStoredProc """ & MyValue & """, """ & MyOtherValue & """",
    Conn
    ' I have also tried the "'" & MyValue & "'" format as well
    ....

    the problem appears to be related to the single quote, as ones without
    quotes seemed to work. Is there escaping and is their URI escaping?

    Thanks,BB
     
    bobbyballgame, Jul 3, 2003
    #1
    1. Advertising

  2. bobbyballgame

    Ray at Guest

    http://www.aspfaq.com/2035

    Ray at work

    "bobbyballgame" <> wrote in message
    news:ei7fi%...
    > I am having a problem calling Stored Procedures:
    >
    > ...
    > dim MyValue, MyOtherValue
    >
    > MyValue = "Bobby's value"
    > MyOtherValue = Bobby's other value"
    >
    > rs.Open "exec MyStoredProc """ & MyValue & """, """ & MyOtherValue &

    """",
    > Conn
    > ' I have also tried the "'" & MyValue & "'" format as well
    > ...
    >
    > the problem appears to be related to the single quote, as ones without
    > quotes seemed to work. Is there escaping and is their URI escaping?
    >
    > Thanks,BB
    >
    >
     
    Ray at, Jul 3, 2003
    #2
    1. Advertising

  3. bobbyballgame

    Bob Barrows Guest

    You can avoid all these delimiter-and-escaping headaches by using this
    method to call your procedure:

    Conn.MyStoredProc MyValue,MyOtherValue

    HTH,
    Bob Barrows
    PS. Do not use this technique if you are planning to run this page via
    dotnet.

    bobbyballgame wrote:
    > I am having a problem calling Stored Procedures:
    >
    > ...
    > dim MyValue, MyOtherValue
    >
    > MyValue = "Bobby's value"
    > MyOtherValue = Bobby's other value"
    >
    > rs.Open "exec MyStoredProc """ & MyValue & """, """ & MyOtherValue &
    > """", Conn
    > ' I have also tried the "'" & MyValue & "'" format as well
    > ...
    >
    > the problem appears to be related to the single quote, as ones without
    > quotes seemed to work. Is there escaping and is their URI escaping?
    >
    > Thanks,BB
     
    Bob Barrows, Jul 3, 2003
    #3
  4. All ' become '' (two single quotes)

    MyValue = "Bobby's value"
    MyOtherValue = Bobby's other value"

    rs.Open "exec MyStoredProc """ & ConvertSingleQuotes(MyValue) & """, """ &
    ConvertSingleQuotes(MyOtherValue) & """",
    Conn
    ' I have also tried the "'" & MyValue & "'" format as well


    Function ConvertSingleQuotes(InputVal)
    ConvertSingleQuotes = Replace(InputVal,"'","''")
    End Function


    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    Author: ADO.NET and XML: ASP.NET on the Edge

    ****************************************************************************
    ****
    Think Outside the Box!
    ****************************************************************************
    ****
    "bobbyballgame" <> wrote in message
    news:ei7fi%...
    > I am having a problem calling Stored Procedures:
    >
    > ...
    > dim MyValue, MyOtherValue
    >
    > MyValue = "Bobby's value"
    > MyOtherValue = Bobby's other value"
    >
    > rs.Open "exec MyStoredProc """ & MyValue & """, """ & MyOtherValue &

    """",
    > Conn
    > ' I have also tried the "'" & MyValue & "'" format as well
    > ...
    >
    > the problem appears to be related to the single quote, as ones without
    > quotes seemed to work. Is there escaping and is their URI escaping?
    >
    > Thanks,BB
    >
    >
     
    Cowboy \(Gregory A. Beamer\), Jul 3, 2003
    #4
  5. Bob,
    Thanks, I would like to avoid delimiter, escaping, encoding, charsets -->
    whatever I can. However, using your method it is not clear how you would get
    the resultSet. Is there a way?

    Thanks,
    BB

    "Bob Barrows" <> wrote in message
    news:u%...
    > You can avoid all these delimiter-and-escaping headaches by using this
    > method to call your procedure:
    >
    > Conn.MyStoredProc MyValue,MyOtherValue
    >
    > HTH,
    > Bob Barrows
    > PS. Do not use this technique if you are planning to run this page via
    > dotnet.
    >
    > bobbyballgame wrote:
    > > I am having a problem calling Stored Procedures:
    > >
    > > ...
    > > dim MyValue, MyOtherValue
    > >
    > > MyValue = "Bobby's value"
    > > MyOtherValue = Bobby's other value"
    > >
    > > rs.Open "exec MyStoredProc """ & MyValue & """, """ & MyOtherValue &
    > > """", Conn
    > > ' I have also tried the "'" & MyValue & "'" format as well
    > > ...
    > >
    > > the problem appears to be related to the single quote, as ones without
    > > quotes seemed to work. Is there escaping and is their URI escaping?
    > >
    > > Thanks,BB

    >
    >
     
    bobbyballgame, Jul 3, 2003
    #5
  6. bobbyballgame

    Bob Barrows Guest

    I'm sorry. i showed you how to execute a non-records-returning procedure. Te
    execute a procedure that returns records, first instantiate a recordset
    object:
    set rs=server.createobject("adodb.recordset")

    then use the recordset variable as the last argument in the procedure call:
    Conn.MyStoredProc MyValue,MyOtherValue, rs

    HTH,
    Bob Barrows

    bobbyballgame wrote:
    > Bob,
    > Thanks, I would like to avoid delimiter, escaping, encoding, charsets
    > --> whatever I can. However, using your method it is not clear how
    > you would get the resultSet. Is there a way?
    >
    > Thanks,
    > BB
    >
    > "Bob Barrows" <> wrote in message
    > news:u%...
    >> You can avoid all these delimiter-and-escaping headaches by using
    >> this method to call your procedure:
    >>
    >> Conn.MyStoredProc MyValue,MyOtherValue
    >>
    >> HTH,
    >> Bob Barrows
    >> PS. Do not use this technique if you are planning to run this page
    >> via dotnet.
    >>
    >> bobbyballgame wrote:
    >>> I am having a problem calling Stored Procedures:
    >>>
    >>> ...
    >>> dim MyValue, MyOtherValue
    >>>
    >>> MyValue = "Bobby's value"
    >>> MyOtherValue = Bobby's other value"
    >>>
    >>> rs.Open "exec MyStoredProc """ & MyValue & """, """ & MyOtherValue
    >>> & """", Conn
    >>> ' I have also tried the "'" & MyValue & "'" format as well
    >>> ...
    >>>
    >>> the problem appears to be related to the single quote, as ones
    >>> without quotes seemed to work. Is there escaping and is their URI
    >>> escaping?
    >>>
    >>> Thanks,BB
     
    Bob Barrows, Jul 3, 2003
    #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. Ben

    Escaping ' in Javascript ?

    Ben, Nov 7, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    9,339
    mikeb
    Nov 10, 2003
  2. Swanand Mokashi

    Re: Escaping a URL in XSL/T

    Swanand Mokashi, May 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    544
    Swanand Mokashi
    May 13, 2004
  3. Teemu Keiski

    Re: Escaping a URL in XSL/T

    Teemu Keiski, May 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    532
    Teemu Keiski
    May 13, 2004
  4. George Durzi

    Escaping a CrLf in JavaScript

    George Durzi, Jul 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    3,431
    George Durzi
    Jul 6, 2004
  5. Mike P

    escaping characters

    Mike P, Mar 29, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    384
    Karl Seguin [MVP]
    Mar 29, 2006
Loading...

Share This Page