At sortere via dato
Jeg har en database, som indeholder nogle nyhedsbreve, som gerne løbende skulle udvides med nye nyhedsbreve.Jeg har sat mit recordset således, at jeg får vist de seneste 10 nyhedsbreve - jeg sorterer via dato.
Men det virker ikke. Jeg får vist poster i vilkårlig rækkefølge.
Jeg kan af en eller anden grund kun hente nul ud fra mit datofelt i min accessbase?
Her er koden:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../../../Connections/Connelaw.asp" -->
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_Connelaw_STRING
Recordset1.Source = "SELECT * FROM elawalert ORDER BY elawalertdato DESC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then MM_removeList = MM_removeList & "&" & MM_paramName & "="
MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""
' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
End If
Next
' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
End If
Next
' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth <> "") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL <> "") Then MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm <> "") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
Dim Repeat1__numRows
Repeat1__numRows = 10
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
Dim elawalertoverskrift
Dim LCaseString
elawalertoverskrift = "VBSCript"
LCaseString = LCase(elawalertoverskrift)
%>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
function DoDateTime(str, nNamedFormat, nLCID)
dim strRet
dim nOldLCID
strRet = str
If (nLCID > -1) Then
oldLCID = Session.LCID
End If
On Error Resume Next
If (nLCID > -1) Then
Session.LCID = nLCID
End If
If ((nLCID < 0) Or (Session.LCID = nLCID)) Then
strRet = FormatDateTime(str, nNamedFormat)
End If
If (nLCID > -1) Then
Session.LCID = oldLCID
End If
DoDateTime = strRet
End Function
</SCRIPT>
<html>
<head>
<title>Elawalert</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#1C3855" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<table width="346" border="0" cellspacing="0" cellpadding="0" height="188">
<tr>
<td height="42"><img name="b" src="../../java/juridiske_nyheder_oppe.gif" border="0" hspace="0" width="220" height="47"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><img border="0" src="../../java/nyhedsbrevetoppe.gif" width="150" height="34"></td>
</tr>
<tr>
<td>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<A HREF="indhold.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "elawalertID=" & Recordset1.Fields.Item("elawalertID").Value %>"><%=(Recordset1.Fields.Item("elawalertoverskrift").Value)%></A><%= DoDateTime((Recordset1.Fields.Item("elawalertdato").Value), 0, -1) %><br>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</td>
</tr>
</table>
</body>
</html>
<%
Recordset1.Close()
%>
