469,342 Members | 5,580 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

What is this ??

Hi guys,

can anyone explain line number 5 to me. i don't quite understand what
is going on there and why.

1 <script language="vbscript" runat="server">sub Application_OnStart
2 getcustomers
3 end subsub getcustomers

4 set conn=Server.CreateObject("ADODB.Connection")
5 conn.Provider="Microsoft.Jet.OLEDB.4.0"
6 conn.Open "c:/webdata/northwind.mdb"
7 set rs=conn.execute("select name from customers")
8 Application("customers")=rs.GetRows
9 rs.Close
10 conn.Close
11 end sub</script>
also what is the meaning of the key word set here. is it an array? is
it a connection ( i ask this cos it gets "closed" later in line 9)

also i presume that customer would need to be declared somewhere as...
dim customers(aNumber). am i correct?

if so, how would i be sure that the size given to the "customers"
array would be big enough?
is there such thing as an array that can hold any number of elements
in ASP?

thanks guys.

Liza
Jul 19 '05 #1
1 1853
Some of your questions go beyond what can be taught in a newsgroup post, but
I'll try. Here is the online ADO Programmers Guide:
http://msdn.microsoft.com/library/en...troduction.asp

Liza wrote:
Hi guys,

can anyone explain line number 5 to me. i don't quite understand what
is going on there and why.

1 <script language="vbscript" runat="server">sub Application_OnStart
2 getcustomers
3 end subsub getcustomers

4 set conn=Server.CreateObject("ADODB.Connection")
5 conn.Provider="Microsoft.Jet.OLEDB.4.0"
ADO (ActiveX Data Objects) is the technology used to allow your
vbscript/jscript/vb/etc. code to interface with databases. It consists of
several COM objects that expose the methods and properties required to work
with data from various databases. OLEDB is the name of the code foundation
that is used by ADO objects. OLEDB connects to various databases via the use
of Providers which can come from Microsoft (these are included in the
Microsoft Data Access Components (MDAC) installation package available from
www.microsoft.com/data - MDAC is automatically installed with later versions
of IE and is included as part of the operating system in Windows 2000/XP and
later), or from non-MS database suppliers. There is an older database
technology called ODBC which can still be used in ADO using the MS OLEDB
Provider for ODBC (MSDASQL), but this is not recommended because it forces
you to use two software layers to get to your data (OLEDB and ODBC).
Instead, you should use the native Providers for your specific database.

In this case, it looks like you're attempting to connect to an Access (Jet)
database, using the native Jet OLEDB version 4.0 provider. You can find many
examples of connection strings at www.able-consulting.com/ado_conn.htm.

6 conn.Open "c:/webdata/northwind.mdb"
7 set rs=conn.execute("select name from customers")
8 Application("customers")=rs.GetRows
9 rs.Close
10 conn.Close
11 end sub</script>
also what is the meaning of the key word set here. is it an array? is
it a connection ( i ask this cos it gets "closed" later in line 9)
In general, "set" is used to cause a variable to refer to a binary object
(usually a COM object), so that the variable behaves as if it WAS that
binary object. In line 4 it was used to cause conn to refer to an ADODB
Connection object that was returned by the CreateObject method. In line 7,
it is being used to cause the variable called rs to refer to the ADODB
Recordset object that is being returned by the Connection object's Execute
method.

In line 8, an Application variable is being set to the array that is being
returned from the Recordset object's GetRows method.

also i presume that customer would need to be declared somewhere as...
dim customers(aNumber). am i correct?
No, Application and Session variables do not need to be declared. Once
created, they are available to any page belonging to the Application or
Session. Do not be tempted to store ADO objects in Application or Session:
it may be counter-intuitive, but storing a "global" COM object can severely
impair an application's performance since only one page at a time will be
able to use it.

if so, how would i be sure that the size given to the "customers"
array would be big enough?
The array returned by GetRows is created behind the scenes: you do not have
to worry about sizing it.
is there such thing as an array that can hold any number of elements
in ASP?

http://msdn.microsoft.com/library/de...svariables.asp

Do you have the vbscript documentation? here is the link where you can
download it:
http://tinyurl.com/7rk6

Here are some good asp resources:
www.learnasp.com
www.4guysfromrolla.com
www.aspfaq.com
www.asp101.com

HTH,
Bob Barrows
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Randell D. | last post: by
220 posts views Thread by Brandon J. Van Every | last post: by
699 posts views Thread by mike420 | last post: by
9 posts views Thread by Martin Maney | last post: by
92 posts views Thread by Reed L. O'Brien | last post: by
3 posts views Thread by Ron_Adam | last post: by
12 posts views Thread by Dario | last post: by
30 posts views Thread by James Conrad StJohn Foreman | last post: by
2 posts views Thread by yogesh | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | 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.