[an error occurred while processing this directive]

Visual Basic on the Web


Explore the power of ASP


F04  Visual Basic on the Web
Kiley McDaniel, P.V.N.C. CDSB
Learn about dynamic Web design concepts using VBScript or Active Server Pages (ASP). This is the VB equivalent of Perl and CGI and will provide you with great ideas for ICS3 and beyond courses. Learn how to use the Windows 98 Personal Web Server and ODBC to test scripts. http://kdoginc.hypermart.net
Audience: S PS
Strand: Computer Studies/Science
Audience Prerequisite: Advanced VB and HTML skills
Computer: WIN

K-DOG's Favorite Active Server Page Sites


ASP 101
4 Guys From Rolla
Planet Source Code
ASP Free
Learn ASP
Kathi's Place - ASP resources
Brinkster - free online ASP server

PWS BUG REPORT

VBScript and ASP Lessons - UNDER CONSTRUCTION


Day 1 Lesson - Introduction
Day 1B Lesson - Dynamic Web Design and Personal Web Server (PWS)
Day 2 Lesson - My First ASP
Day 3 Lesson - VBScript activities
Day 4 Lesson - Configure ODBC and using Databases Online
Day 5 Lesson - Project Ideas
Networking Home Computers
Download sample ASP code and Spy database

A simple ASP



VBScript code used to create "My First ASP" above is listed below


<html> <head> <title>My First ASP script</title> </head> <body> <font face="arial" size=4> <% Dim Today ' declares Today as a variable Today = Date() ' makes Today's value today's date Response.Write "Hello, ASP World!" Response.write "<br>My first script was created " response.Write(Today) ' now we'll end the response response.end %> </font> </center> </body> </html>

Accessing databases online using VBScript and ASP



A simple ASP poll




The Test ASP - Please enter an eye colour for spy match:



Please select an eye colour:



Source Code for Spy Search VBScript/ASP application


<html> <head> <meta http-equiv="expires" content="0"> </head> <body bgcolor="#ffffff"> <center> <table width=600 border=1 cellpadding=5 cellspacing=0> <tr> <td colspan=3 align="center"> <font face="arial"> <h1>The Spy Search</h1></font> </td> </tr> <tr> <td><b>Location</b></td> <td><b>Last Name</b></td> <td><b>Specialty</b></td> </tr> <% dim strFilename Dim Conn Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\inetpub\wwwroot\spy.mdb" strFilename = Request.ServerVariables("SCRIPT_NAME") SQLtemp = "SELECT * FROM spyfile where eyes = '" & Request.QueryString("keyword") & "'" response.write SQLtemp 'COOL STUFF TO TRY response.write "<br>" Response.Write(FormatDateTime(Now(),1) & " " ) response.write "<br>" 'displays date '12 hour format: response.write time 'Result: 11:28:09 PM response.write "<br>" Response.Write(Session.SessionID) response.write "<br>" response.write strFilename response.write "<br>" 'response.write(server.mappath("\localhost\wwwroot")) response.write "<br>" set rs = server.createobject("ADODB.recordset") rs.Open SQLtemp, Conn Set rs = Conn.Execute(SQLtemp) while not rs.eof %> <p> <% If request.querystring = "" then response.write "Sorry, no results found." else %> <% loca=rs("location") name=rs("lname") spec=rs("specialty") %> <tr> <td><%=loca%></td> <td><%=name%></td> <td><%=spec%></td> </tr> <% End If %> <p> <% rs.MoveNext Wend rs.Close Conn.Close set Conn = Nothing %> </td> </tr> </table> </center> </body> </html>

The COOP Test ASP - Please enter a job type for matching records:


VBScript Sites and Samples - View Source Code

VBScript Language Reference
VBScript Examples
Planet Source on VBScript/ASP

Simple Validation - Decision
Enter a value between 1 and 10:


Simple Random - Decision
Random Page - see code below

Click Refresh/Reload several times to see Random function at work

<% Randomize if INT(2*RND) = 1 then %> <html> <head><title>First Page</title></head> <body> This is the first page </body> </html> <% else %> <html> <head><title>Second Page</title></head> <body> This is the second page </body> </html> <% end if %>
Using Random Numbers
Generate a random number between and
Greetings using VBScript - Decision/Repetition


2977



Choose:   K-DOG Home   I   Contact Us