'AS' keyword supported?

Discussion in 'ASP General' started by Sean S - Perth, WA, Apr 19, 2006.

  1. Hi all,

    Is the keyword 'as' supported in ASP? I'm reasonably sure it's valid
    VBScript (code examples I've downloaded use it) but when I try to use it in
    ASP I get an error. Is it perhaps a version issue?


    Expected end of statement

    Dim conn As New ADODB.Connection
    ---------^


    --
    Sean.
    Sean S - Perth, WA, Apr 19, 2006
    #1
    1. Advertising

  2. Sean S - Perth, WA

    Mike Brind Guest

    Sean wrote:
    > Hi all,
    >
    > Is the keyword 'as' supported in ASP? I'm reasonably sure it's valid
    > VBScript (code examples I've downloaded use it) but when I try to use it in
    > ASP I get an error. Is it perhaps a version issue?
    >
    >
    > Expected end of statement
    >
    > Dim conn As New ADODB.Connection
    > ---------^


    Nope. That's VB.

    VBscript is as follows:

    Dim conn
    SET conn = CreateObject("ADODB.Connection")

    --
    Mike Brind
    Mike Brind, Apr 19, 2006
    #2
    1. Advertising

  3. Sean S - Perth, WA wrote:
    > Hi all,
    >
    > Is the keyword 'as' supported in ASP? I'm reasonably sure it's valid
    > VBScript (code examples I've downloaded use it)


    Those must be VB examples, not vbscript ...

    > but when I try to use
    > it in ASP I get an error. Is it perhaps a version issue?


    ASP is not a language: it is a platform that supports the use of several
    scripting languages, including vbscript, jscript and perlscript.

    >
    >
    > Expected end of statement
    >
    > Dim conn As New ADODB.Connection
    > ---------^


    In vbscript, only variants are allowed, so no, the "AS [New] datatype" is
    not allowed.

    See the two topics about the differences between VB and VBScript in the
    documentation you can download from: http://tinyurl.com/7rk6

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Apr 19, 2006
    #3
  4. Sean S - Perth, WA

    Guffa Guest

    > VBscript is as follows:
    >
    > Dim conn
    > SET conn = CreateObject("ADODB.Connection")


    But in ASP use Server.CreateObject instead of CreateObject.
    Guffa, Apr 19, 2006
    #4
  5. Guffa wrote:
    >> VBscript is as follows:
    >>
    >> Dim conn
    >> SET conn = CreateObject("ADODB.Connection")

    >
    > But in ASP use Server.CreateObject instead of CreateObject.


    That's debatable as well.
    http://blogs.msdn.com/ericlippert/archive/2004/06/01/145686.aspx

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Apr 19, 2006
    #5
  6. Sean S - Perth, WA

    Guffa Guest

    Guffa, Apr 19, 2006
    #6
  7. Guffa wrote:
    >> That's debatable as well.
    >> http://blogs.msdn.com/ericlippert/archive/2004/06/01/145686.aspx

    >
    > Of course it is. Here's something for the debate:
    >
    > Would you like to create a connection object in 0.4 ms or 0.15 ms?


    The latter, of course. What are you saying? That you've got benchmark code
    that proves CreateObject instantiates connection objects faster than
    Server.CreateObject? If so, we'd all like to see it.

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Apr 19, 2006
    #7
  8. Sean S - Perth, WA

    Guffa Guest

    > The latter, of course. What are you saying? That you've got benchmark code
    > that proves CreateObject instantiates connection objects faster than
    > Server.CreateObject? If so, we'd all like to see it.


    No, the opposite. Server.CreateObject is faster than CreateObject, as it
    reuses the objects from the object pool.

    The benchmark code is really simple:

    <%

    Dim a, t, obj

    t = Timer
    For a = 1 to 100000
    Set obj = Server.CreateObject("ADODB.Connection")
    Set obj = Nothing
    Next
    Response.Write Timer - t & "<br>"

    t = Timer
    For a = 1 to 100000
    Set obj = CreateObject("ADODB.Connection")
    Set obj = Nothing
    Next
    Response.Write Timer - t & "<br>"

    %>

    /Guffa
    Guffa, Apr 19, 2006
    #8
  9. Guffa wrote:
    > Server.CreateObject is faster than CreateObject, as
    > it reuses the objects from the object pool.


    Even if you can show that Server.CreateObject is faster, I'm not sure you
    have the correct reason.

    I use JScript on the Server, so CreateObject() alone is not an option (but
    new ActiveXObject() is). I assume that's because JScript doesn't go looking
    for the method in all of its available objects (Response, Server, Session,
    etc.) if you don't specify one. VBScript *will* do this, so I further assume
    it is using the CreateObject method of the Server Object anyway -- it just
    has to find it each time it is called lazily.



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms.
    Dave Anderson, Apr 19, 2006
    #9
  10. Sean S - Perth, WA

    Guffa Guest

    "Dave Anderson" wrote:

    > Guffa wrote:
    > > Server.CreateObject is faster than CreateObject, as
    > > it reuses the objects from the object pool.

    >
    > Even if you can show that Server.CreateObject is faster, I'm not sure you
    > have the correct reason.
    >
    > I use JScript on the Server, so CreateObject() alone is not an option (but
    > new ActiveXObject() is). I assume that's because JScript doesn't go looking
    > for the method in all of its available objects (Response, Server, Session,
    > etc.) if you don't specify one. VBScript *will* do this, so I further assume
    > it is using the CreateObject method of the Server Object anyway -- it just
    > has to find it each time it is called lazily.
    >


    No, VBScript doesn't look for methods in the ASP objects. If you for an
    example try to use just Write instead of Response.Write, it won't work.

    Server.CreateObject is a method in the Server object, while CreateObject is
    a command in VBScript.
    Guffa, Apr 19, 2006
    #10
  11. "Mike Brind" wrote:

    > Nope. That's VB.


    Ahhhhhhhhhh. <light bulb goes on>

    Thanks to Bob B. too.

    --
    Sean.
    Sean S - Perth, WA, Apr 20, 2006
    #11
    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. Carl

    Keyword not supported

    Carl, Aug 1, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,111
    Kevin Cunningham
    Aug 1, 2003
  2. Frank Bishop

    Keyword Not Supported Error

    Frank Bishop, May 30, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    568
    Eliyahu Goldin
    May 30, 2005
  3. =?Utf-8?B?dnZlbms=?=
    Replies:
    3
    Views:
    22,031
    sean557
    Mar 28, 2009
  4. Kev

    Keyword not supported - Provider

    Kev, Jan 6, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    144
  5. Danijel Valentic

    Keyword not supported

    Danijel Valentic, Aug 31, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    184
Loading...

Share This Page