Vista Software
Apollo ASP Sample

Apollo ASP™

Apollo ASP Sample Code

The following are a few excerpts that perform simple operations to a data table and shows how to use QuickMail™ to send -mails:

Download Apollo ASP Samples (359 kb)


SaveCustomer

This SaveCustomer function takes data that was input into an ASP page (i.e. a web form) and stores the data into a table called CUSTREG.DBF. The web form has several fields defined: FName, LName, Company and Email. The sample usese the ASP server object called "Request" to access the fields.

Function SaveCustomer
DIM sFName, sLName, sCompany, sEmail

' Create Apollo ASP Query object
set oApollo = Server.CreateObject("ApolloASP61.Query")
oApollo.DatabaseName = "\inetpub\wwwroot\myweb\data\"

' Set the variables based on input from the web form
sFName = Request.Form("FName")
sLName = Request.Form("LName")
sCompany = Request.Form("Company")
sEmail = Request.Form("Email")

' SQL statement to execute
oApollo.SQL = "INSERT INTO CUSTREG (FName, LName, Company, Email) VALUES ( '"+ sFNAME+"','"+ sLName +"','"+ sCompany+"','"+ sEmail +"' )"

' Execute the SQL statement!
oApollo.ExecSQL

' Close the query and clear the object from memory
oApollo.Close

set oApollo = nothing

End Function


ShowCustomer

This ShowCustomer function displays all the records in CUSTREG that match the Last Name entered in the ASP page.

Function ShowCustomer
DIM sFName, sLName, sCompany, sEmail

' Create Apollo ASP Query object
set oApollo = Server.CreateObject("ApolloASP61.Query")
oApollo.DatabaseName = "\inetpub\wwwroot\myweb\data\"

' Extract Last Name from the the web page
sLName = Request.Form("LName")

' SQL statement to execute
oApollo.SQL = "SELECT * FROM CustReg
                          WHERE LNAME = '"+sLName+"'"

' Open the SQL statement!
oApollo.Open

while ( not oApollo.Eof )
   ' Store data from query to temp variables for legibility
   sFName = oApollo.FieldByName("FName")
   sLName = oApollo.FieldByName("LName")
   sCompany = oApollo.FieldByName("Company")
   sEmail = oApollo.FieldByName("Email")

   ' Output the record data to the web page
   Response.Write("<br>"+sFName +" " + sLName +" "+
   sCompany +" "+ sEmail )'+ "" )

   ' Move to the next record
   oApollo.Next
wend

' Close the query and clear the object from memory
oApollo.Close

set oApollo = nothing

End Function


ShowClipper

This ShowClipper function shows how to access a Clipper table with multiple NTX indexes using the optional SetTables method

Function ShowClipper
DIM sFName, sLName, sCompany, sEmail

' Create Apollo ASP Query object
set oApollo = Server.CreateObject("ApolloASP61.Query")
oApollo.DatabaseName = "\inetpub\wwwroot\myweb\data\"

' List the tables and NTX indexes to use in the query
' SetTables( TableName, Alias, TableType, Password,
                    OEMTranslate, ExtraIndexes )

oApollo.SetTables "CLIPPER.DBF", "CLIPPER", "ttSXNTX", "",
                        FALSE, "CLIP1.NTX, CLIP2.NTX"

' Extract Last Name from the the web page
sLName = Request.Form("LName")

' SQL statement to execute
oApollo.SQL = "SELECT * FROM Clipper
                          WHERE LNAME = '"+sLName+"'"

' Open the SQL statement!
oApollo.Open

while ( not oApollo.Eof )
   ' Store data from query to temp variables for legibility
   sFName = oApollo.FieldByName("FName")
   sLName = oApollo.FieldByName("LName")
   sCompany = oApollo.FieldByName("Company")
   sEmail = oApollo.FieldByName("Email")

   ' Output the record data to the web page
   Response.Write("<br>"+sFName +" " + sLName +" "+
                                 sCompany +" "+ sEmail )'+ "" )

   ' Move to the next record
   oApollo.Next
wend

' Close the query and clear the object from memory
oApollo.Close

set oApollo = nothing

End Function


SendEmail

SendEmail shows how to use the QuickMail™ e-mail component that comes with Apollo ASP. This example uses phony mail server information, so it will not work as shown until the mail server host is changed.

Function SendEmail

DIM objMail

' Create Apollo QuickMail object
set objMail = Server.CreateObject("ApolloASP61.QuickMail")

' Change the following information to your web server
objMail.host = "mail.mycompany.com"
objMail.FromAddress = "info@mycompany.com"
objMail.FromName = "Apollo Sample"
objMail.Subject = "Apollo ASP is Great!"
objMail.Body = "Apollo ASP is the best database for web developers!"
objMail.MailFormat = 0 ' (0=Plain Text, 4=HTML)
objMail.ToAddress = Request.form("Email")

' We are ready to send the e-mail!
objMail.SendMail

' Clear the object from memory
set objMail = nothing

End Function

Apollo Database Engines