469,366 Members | 2,342 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

'AS' keyword supported?

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.
Apr 19 '06 #1
10 1458

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

Apr 19 '06 #2
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"
Apr 19 '06 #3
> VBscript is as follows:

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


But in ASP use Server.CreateObject instead of CreateObject.
Apr 19 '06 #4
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/ar...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"
Apr 19 '06 #5
> That's debatable as well.
http://blogs.msdn.com/ericlippert/ar...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?
Apr 19 '06 #6
Guffa wrote:
That's debatable as well.
http://blogs.msdn.com/ericlippert/ar...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"
Apr 19 '06 #7
> 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
Apr 19 '06 #8
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.
Apr 19 '06 #9
"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.
Apr 19 '06 #10
"Mike Brind" wrote:
Nope. That's VB.


Ahhhhhhhhhh. <light bulb goes on>

Thanks to Bob B. too.

--
Sean.

Apr 20 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Klaus Johannes Rusch | last post: by
1 post views Thread by Sid | last post: by
1 post views Thread by Frank Bishop | last post: by
12 posts views Thread by Viru Rathore | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.