Docsity

Parameters - E-Commerce - Lecture Slides, Slides of Fundamentals of E-Commerce

Toggle sidebar
bg1
Setting up the passed parameters
'Notice that we create the local variables from BOTH the
'querystring() and form() Arguments by using the shortcut notation.
SEARCH=Trim(request("SEARCH"))
'The numeric ones demonstrate a trick for converting to a number quickly
FLAG=cInt("0" & Trim(request("FLAG")) )
PAGE=cInt("0" & Trim(request("PAGE")) )
C1=cInt("0" & Trim(request("C1")) )
C2=cInt("0" & Trim(request("C2")) )
C3=cInt("0" & Trim(request("C3")) )
'If no flags are selected default to title.
If (C1 + C2 + C3) = 0 then C1=1
'Create a QueryString for use in the paging hyperlinks
myRETURN = MakeReturn(SEARCH,C1,C2,C3) '...
'F(X) To make the arguments for the hyperlinks (called the return in this example)
Function MakeReturn(SearchText, F1, F2, F3)
MakeReturn ="&C1=" & F1 & "&C2=" & F2 & "&C3=" & F3 &
"&SEARCH=" & SearchText
Exit Function
End Function
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Parameters - E-Commerce - Lecture Slides and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

Setting up the passed parameters 'Notice^ that^

we^ create

the^ local

variables

from^ BOTH

the

' querystring

()^ and^ form ()^ Arguments

by^ using

the^ shortcut

notation.

SEARCH=Trim(request("SEARCH"))'The numeric

ones^ demonstrate

a^ trick

for^ converting

to^ a^ number

quickly

FLAG=cInt("0"

&^ Trim(request("FLAG"))

PAGE=cInt("0"

&^ Trim(request("PAGE"))

C1=cInt("0" &

Trim(request("C1")) ) C2=cInt("0" &

Trim(request("C2")) ) C3=cInt("0" &

Trim(request("C3")) ) 'If^ no^ flags^ are

selected

default to title.

If^ (C^

+^ C2 +^

C3)^ =^0

then^ C1=

'Create a^ QueryString

for^ use

in^ the paging

hyperlinks

myRETURN

=^ MakeReturn(SEARCH,C1,C2,C3)

'F(X)^ To

make^ the

arguments for

the^ hyperlinks

(called

the^ return

in^ this

example)

Function

MakeReturn(SearchText,

F1,^ F2,

F3)

MakeReturn

="&C1="

&^ F1 &^

"&C2="

&^ F2^ &

"&C3="

&^ F3^ &

"&SEARCH="

&^ SearchText

Exit^ Function End^ Function

Notes on parameter passing

•^ Every link to a page needs to include^ –^

Page desired (1 - Page Count)– All of the search parameters (e.g. Search, C1-C3)– A flag that indicates the results page is needed

•^ In this design, a function MakeReturn() creates the querystring for the search parameters that can be appended toeach of the hyper links generated thus allowing the queryto be re-executed each time with the same criteria anddifferent pages.•^ This may seem wasteful, but the operation is actually fairlycheap providing the parameters used in the query areindexed.

Creating the page navigation

Function DoNav(myReturn,myPage,MaxPage)dim^ sretsRet = ""sRet = sRet & ""

sRet = sRet & "New Search" sRet = sRet & "Top of Page" if^ myPage^

> 1 thensRet = sRet & "First Page" else

sRet = sRet & " " end^ ifsRet = sRet & "myPage " & myPage &" of " & MaxPage & "" if^ myPage^

> 1 thensRet = sRet & "Previous " & cRECMAX & "" else

sRet = sRet & " " end^ ifif^ myPage^

< MaxPage ThensRet = sRet & "Next " & cRECMAX & "" else

sRet = sRet & " " end^ ifsRet = sRet & ""DoNav^ = sRetexit functionEnd^ Function

Notes about page navigation • We go through all of that trouble to present theuser with only the relevant navigation links.• What is missing is a routine to count the numberof actual records on the last page and display thatinstead of the number of records per page.• The page size of 2 is to force paging for theexample. Obviously, bigger would be better.• The server side cursor used this was is fairly lightweight and the technique is highly scale-able.

Maintaining Databases^ Action queries are our friends

Overview

•^ The web is episodic in nature, so too should be ourdata access•^ IIS 4 is built on MTS that provides connectionpooling. The upshot of this is that connectionobjects normally very expensive to create are quitecheap and fast.•^ Thus, the connection objects execute methodprovides a good way to modify records in thedatabase using the SQL update, insert and deleteverbs.

Editing the author record

Again we pass the actionin the embedded hyperlink