<%
'#################################################################################
'## Copyright (C) 1999-2002 - Matt Smith
'##
'## This program is free software; you can use it and/or
'## modify it as you see fit. I only ask that somewhere in your comments,
'## (you do comment your programs, don't you?) you keep a reference
'## to the original 4GuysFromRolla article which is:
'##
'## http://www.4guysfromrolla.com/webtech/111899-1.shtml
'##
'## Matt Smith
'## Questions: matt@smitty.net
'## PayPal: matt@smitty.net - tipping is appreciated!
'#################################################################################
Const adOpenStatic = 3
Const adCmdText = &H0001
Const adUseClient = 3
Const TITLE = "Novetats"
dim objRS 'Recordset object
dim strSQL 'SQL string
dim intNumRows 'number of rows in table
dim intNumCols 'number of columns in table
dim strLayoutType 'whether intSize refers to (C)olumns or (R)ows
dim strOrientation 'direction of output: (V)ertical or (H)orizontal
dim intNumRecs 'number of records in the database
dim intPage 'current page to disply
dim intPageSize 'number of records to display on page
dim intNumPages 'number of pages
dim intRowIndex 'placeholder for current row
dim intColIndex 'placeholder for current column
dim intPosition 'placeholder for current record
intNumRows = 3
intNumCols = 2
strOrientation = "H"
'strLayoutType = UCase(Request("LayoutType"))
%>
<%
'create recordset object
Set objRS = Server.CreateObject("ADODB.Recordset")
'connect via ODBC
objRS.ActiveConnection = MM_armeriaandorrana_STRING
'create SQL query
strSQL = "SELECT * FROM Marques ORDER BY ID ASC;"
'response.write strSQL
objRS.CursorLocation = adUseClient
'execute SQL statement
objRS.Open strSQL, ,adOpenStatic , , adCmdText
%>
<% If objRS.EOF And objRS.BOF Then %>
No hem trobat cap link a la base de dades.
<% else If NOT objRS.EOF AND NOT objRS.BOF Then
Dim Ref
Ref = objRS.Fields("ID")
'intNumRows = 3
'intNumCols = 2
'strOrientation = "H"
intNumRecs = objRS.RecordCount
intPage = Request("Page")
intPageSize = cint(intNumRows) * cint(intNumCols)
objRS.PageSize = intPageSize
intNumPages = objRS.PageCount
If intPage = "" then
intPage = 1
objRS.AbsolutePage = intPage
else
objRS.AbsolutePage = intPage
end if
Response.Write "
" & vbCRLF
For intRowIndex = 1 To intNumRows
Response.Write "" & vbCRLF
If strOrientation = "V" Then
'intPosition = intRowIndex
'intPosition = ((intPage - 1) * intPageSize) + intColIndex + ((intRowIndex - 1) * intNumCols)
'loop thru table by column
For intColIndex = 1 To intNumCols
intPosition = ((intPage - 1) * intPageSize) + intRowIndex + ((intColIndex - 1) * intNumRows)
PrintRecord
'intPosition = intPosition + intNumRows
Next
Else'If strOrientation = "H" Then
'loop thru table by column
For intColIndex = 1 To intNumCols
intPosition = ((intPage - 1) * intPageSize) + intColIndex + ((intRowIndex - 1) * intNumCols)
PrintRecord
Next
End if
Response.Write "
" & vbCRLF
Response.Write "" & vbCrlf
Response.Write " | " & vbCrlf
Response.Write "
" & vbCrlf
Next
Response.Write "
" & vbCRLF
End if
sub PrintRecord
'if position is past EOF print a blank cell
If intPosition > intNumRecs Then
Response.Write "
| " & vbCRLF
Else
objRS.AbsolutePosition = intPosition
'if necessary, check for blank field values and print blank cell
If objRS.Fields("ID") = "" Then
Response.Write "
| " & vbCRLF
Else
Response.Write "
" & vbCRLF
Response.Write "" & vbCrlf
Response.Write " | " & vbCrlf
End if
End if
End Sub
Function IIF(sExp, sTrue, sFalse)
If CBool((sExp)) = True Then
IIF = sTrue
Else
IIF = sFalse
End if
End Function
'clean up and close the database
objRS.Close
Set objRS = Nothing
End if
%>