Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1

580 rstCustomers.MoveNext


590 'Increase the record count


600 vRecordCount = vRecordCount + 1


610 Loop


620 rstCustomers.Close


630 mConn.Close


640 %>


650


660


670


The very first line of text tells the server that this is an Active Server Page using VBScript. That’s all it
does. The next two lines are simple HTML tags. The first declares this is an HTML page and the second
starts the page heading. The next line is a META tag. This tag tells the browser not to use the browser’s
cache for this file. This is an important line, especially when displaying data results. If the browser were
to use its cache, it may be pulling old data. And as we all know, old data isn’t always correct data. So to
ensure that your users are getting the latest and greatest, use this META tag. The next line closes your
header.
The next batch of code is executed on the server before it ever gets to the browser. This is designated
by the <% tag. An important point to note is that the header is actually loaded to the client. The code you
are creating takes place between the header and the body. This means the client will get all the head
information before this code is executed. This space—between the header and body—is where most
ASP programming is done. It allows some information to get to the client while the rest is being
processed. This is a courtesy to the users so they know something is happening and are not lost in
some cyber space void. The variables are declared in lines 70–120
All variables declared in VBScript are a variant type by default. They will become whatever type is
necessary when they get a value. The first three variables will eventually store objects, while
vRecordCount will hold a number, and vbgcolor will hold a string.

Creating ADO Objects


Lines 130–160 are a little more interesting.
This is where you create ADO objects on the server. This is discussed in a little more depth later today.
For now, examine the interesting event that is occurring here. You are setting your variables here equal
to the results of the CreateObject method of the Server object. You may be asking yourself, "Where
did this Server object come from?" This is a built-in object provided by the Internet Information Server
(IIS). This is what makes an ASP an ASP and not some other Web page. In fact, there are seven built-in
objects. They are the Server object, the Application object, the Request object, the Response
object, the Session object, the ObjectContext object, and the ASPErr object. Each one has a
bunch of useful methods and properties. This book will cover only those pertinent to our present goals.


The Server Object


The Server object, as you have seen has a very important method—CreateObject. This method creates
and instance of the named object on the server. An important point to remember is that the object that you
are calling must be installed on the server and registered properly in the server’s registry. If not, you will not

Free download pdf