<%
' -- Declare Variables
Dim ProductInfo ' Our Recordset Object
Dim strSQL ' Our SQL String to access the database
Dim strConnection ' Our Connection string to access the database
Dim i ' a counter variable
Dim j ' a counter variable
Dim lngPage
' -- Page number from Request Object
lngPage = Request("p")
' -- default value if none provided
if lngPage = "" Then lngPage = 1
' -- make sure it is a long integer
lngPage = Clng(lngPage)
'Get the display operation from the querystring
' The operation determines whether the product information display
' will contain Update or Remove options.
op = Request.QueryString("op")
CategoryID = Request.QueryString("CategoryID")
'Reference the Session connection variable
cn = Session("cnn")
set cn = server.createobject("ADODB.Connection")
cndata = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & Server.MapPath("../www/images/lifeline.mdb")
'cn.open= "DBQ=C:/babucv/\Gallery.mdb;DefaultDir=C:/babucv/;Driver={Microsoft Access Driver (*.mdb)};"
cn.Open cndata,"",""
'Create a recordset
Set CategoryInfo = Server.CreateObject("ADODB.Recordset")
'Create a query string
querystr = "SELECT CategoryName,description, CategoryID FROM Categories Order By CategoryID, CategoryName"
'Open the Recordset with the query string on the connection cn.
CategoryInfo.Open querystr, cn
%>
<%
IF op <> "" THEN
Response.Write ""
END IF
'Output the table headers
For i = 0 To 0
Response.Write ""
NEXT %>
<% 'Loop through the recordset and output the table values
Do While Not CategoryInfo.EOF
Response.Write ""
For i = 0 to 0
Response.Write ""
NEXT
Response.Write " "
CategoryInfo.MoveNext
LOOP %>
<% 'Close the recordset
CategoryInfo.Close %>
|
<%
'Get the CategoryID number from the calling page if any.
CategoryID = Request.QueryString("CategoryID")
'Get the display operation from the calling page if any.
op = Request.QueryString("op")
CategoryID = Request.QueryString("CategoryID")
'Reference the Session connection variable
cn = Session("cnn")
'Create recordsets
'Set ProductInfo = Server.CreateObject("ADODB.Recordset")
Set CategoryInfo = Server.CreateObject("ADODB.Recordset")
'Create query strings
'Returns products from the Products table that belong to the CategoryID category.
querystr = "SELECT ID,groupID,Image,CategoryID FROM productgroup WHERE CategoryID = " & CategoryID & " ORDER BY ID"
'Returns the category name associated with CategoryID
querystr2 = "SELECT CategoryName FROM Categories WHERE CategoryID = " & CategoryID
'Returns all products from the Products table
defaultquery = "SELECT ID,groupID,Image,CategoryID FROM productgroup"
set cn = server.createobject("ADODB.Connection")
cndata = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & Server.MapPath("../www/images/lifeline.mdb")
cn.Open cndata,"",""
'cn.open= "DBQ=C:/Program Files/Microsoft Visual Studio/VB98/\NWIND.mdb;DefaultDir=C:/Program Files/Microsoft Visual Studio/VB98/;Driver={Microsoft Access Driver (*.mdb)};"
'cn.open= "DBQ=C:/babucv/\Gallery.mdb;DefaultDir=C:/babucv/;Driver={Microsoft Access Driver (*.mdb)};"
'Open the Recordsets
IF CategoryID <> "" THEN 'This was a request to view products from only one
'category, only query for products in the category
Set ProductInfo = GetRecordset(cndata, querystr)
' ProductInfo.Open querystr, cn
CategoryInfo.Open querystr2, cn
ELSE 'Retrieve all products in the query
Set ProductInfo = GetRecordset(cndata, defaultquery)
END IF
%>
<%
if (ProductInfo.BOF and ProductInfo.EOF) then
response.write "No records found"
response.end
End if
' -- position the record pointer appropriately
ProductInfo.PageSize = 24
If lngPage <= ProductInfo.PageCount Then
ProductInfo.AbsolutePage = lngPage
End if
ID = Request.QueryString("ID")
%>
<%
IF CategoryID <> "" THEN 'Display the category of products being displayed.
Response.Write CategoryInfo.Fields(0)
CategoryInfo.Close 'Close this Recordset since it will not be used again.
ELSE
Response.Write "All Lifeline Products"
END IF %>
Page Number:<%= lngPage %>
|
|
<%
j = 0
Do While Not ProductInfo.EOF
j = j+1
if ((j mod 2) = 1) Then
Response.Write ""
END IF
Response.Write "| "
if j > 24 then exit do
' -- output the contents
%>
|
<%
if ((j mod 2) = 0) Then
Response.Write " "
END IF
ProductInfo.MoveNext
LOOP
'Close the Recordset
ProductInfo.Close %>
|