Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá, estou precisando de ajuda e ficaria muito grato se alguém pudesse me ajudar.
Tenho um código pra exibir os últimos 10 registros no banco de dados Access, ordenando pelo código do registro em ordem decrescente, que eu fiz no Dreamweaver há muito tempo, só que o código é muito extenso e demora muito pra carregar, será alguém teria alguma alternativa para um código mais simples e compacto. Não sou muito bom com programação, tenho bastante dificuldades.
Os arquivos são estes:
conexao.asp
<%
Dim MM_conexao_STRING
MM_conexao_STRING = "DBQ=" & Server.MapPath("database.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}"
%>
exibir.asp
<!--#include file="conexao.asp" -->
<%
Dim UltimosRegistros
Dim UltimosRegistros_numRows
Set UltimosRegistros = Server.CreateObject("ADODB.Recordset")
UltimosRegistros.ActiveConnection = MM_conexao_STRING
UltimosRegistros.Source = "SELECT * FROM tabela ORDER BY id DESC"
UltimosRegistros.CursorType = 0
UltimosRegistros.CursorLocation = 2
UltimosRegistros.LockType = 1
UltimosRegistros.Open()
UltimosRegistros_numRows = 0
%>
<%
Dim Repeat__numRows
Dim Repeat__index
Repeat__numRows = 10
Repeat__index = 0
UltimosRegistros_numRows = UltimosRegistros_numRows + Repeat__numRows
%>
<%
Dim MMUltimosRegistros_paramName
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
Dim MMUltimosRegistros_keepNone
Dim MMUltimosRegistros_keepURL
Dim MMUltimosRegistros_keepForm
Dim MMUltimosRegistros_keepBoth
Dim MMUltimosRegistros_removeList
Dim MMUltimosRegistros_item
Dim MMUltimosRegistros_nextItem
' create the list of parameters which should not be maintained
MMUltimosRegistros_removeList = "&index="
If (MMUltimosRegistros_paramName <> "") Then
MMUltimosRegistros_removeList = MMUltimosRegistros_removeList & "&" & MMUltimosRegistros_paramName & "="
End If
MMUltimosRegistros_keepURL=""
MMUltimosRegistros_keepForm=""
MMUltimosRegistros_keepBoth=""
MMUltimosRegistros_keepNone=""
' add the URL parameters to the MMUltimosRegistros_keepURL string
For Each MMUltimosRegistros_item In Request.QueryString
MMUltimosRegistros_nextItem = "&" & MMUltimosRegistros_item & "="
If (InStr(1,MMUltimosRegistros_removeList,MMUltimosRegistros_nextItem,1) = 0) Then
MMUltimosRegistros_keepURL = MMUltimosRegistros_keepURL & MMUltimosRegistros_nextItem & Server.URLencode(Request.QueryString(MMUltimosRegistros_item))
End If
Next
' add the Form variables to the MMUltimosRegistros_keepForm string
For Each MMUltimosRegistros_item In Request.Form
MMUltimosRegistros_nextItem = "&" & MMUltimosRegistros_item & "="
If (InStr(1,MMUltimosRegistros_removeList,MMUltimosRegistros_nextItem,1) = 0) Then
MMUltimosRegistros_keepForm = MMUltimosRegistros_keepForm & MMUltimosRegistros_nextItem & Server.URLencode(Request.Form(MMUltimosRegistros_item))
End If
Next
' create the Form + URL string and remove the intial '&' from each of the strings
MMUltimosRegistros_keepBoth = MMUltimosRegistros_keepURL & MMUltimosRegistros_keepForm
If (MMUltimosRegistros_keepBoth <> "") Then
MMUltimosRegistros_keepBoth = Right(MMUltimosRegistros_keepBoth, Len(MMUltimosRegistros_keepBoth) - 1)
End If
If (MMUltimosRegistros_keepURL <> "") Then
MMUltimosRegistros_keepURL = Right(MMUltimosRegistros_keepURL, Len(MMUltimosRegistros_keepURL) - 1)
End If
If (MMUltimosRegistros_keepForm <> "") Then
MMUltimosRegistros_keepForm = Right(MMUltimosRegistros_keepForm, Len(MMUltimosRegistros_keepForm) - 1)
End If
' a utility function used for adding additional parameters to these strings
Function MMUltimosRegistros_joinChar(firstItem)
If (firstItem <> "") Then
MMUltimosRegistros_joinChar = "&"
Else
MMUltimosRegistros_joinChar = ""
End If
End Function
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Exibe registros</title>
</head>
<body></body>
</html>
Muito obrigado.
Carregando comentários...