04. februar 2002 - 13:09Der er
2 kommentarer og 1 løsning
Viser forkert dato
På følgende link har jeg sat den til at vise forum spørgsmålene, sorteret pr. dato, som den henter fra en access 2000 database. Men når den henter den, sker det nogle gange at den bytter om på rækkefølgen. F. eks. kan den finde på at srive den 4. februar som en af de to nedenstående:
04.02.02 eller 02.04.02
Det vil sige i det ene tilfælde tælle den det som april istedet for februar. Hvad er der galt, hvorhenne ligger fejlen.
Dim curPage, pageCount, topicCount Dim sortBy, sortDir, sortDirOpp Dim strSearch Dim strSQL Dim dbRS Dim stateQS Dim i, x, c
x = 0
'get the new current page if available - otherwise set to 1
curPage = CInt(Request("curPage")) If curPage = "" Or IsNumeric(curPage) = False Then curPage = 1 Else If curPage < 1 Then curPage = 1 End If End If
'get sort settings
If Request("sortBy") = "" Then sortBy = Session("sortBy") Else sortBy = Request("sortBy") End If If Request("sortDir") = "" Then sortDir = Session("sortDir") Else sortDir = Request("sortDir") End If
If sortBy = "" Then sortBy = "date_posted" End If If sortDir = "" Then sortDir = "DESC" End If
'get the opposite of the current sort direction in case of change If sortDir = "DESC" Then sortDirOpp = "ASC" ElseIf sortDir = "ASC" Then sortDirOpp = "DESC" End If
'get the search string and build the SQL statement
strSearch = Request("search")
strSQL = "SELECT ID,parentID,topic,author,date_posted,replies FROM board1 " If Not strSearch = "" Then strSQL = strSQL & "WHERE (topic LIKE '%" & web2db(strSearch) & "%' OR" strSQL = strSQL & " body LIKE '%" & web2db(strSearch) & "%' OR" strSQL = strSQL & " author LIKE '%" & web2db(strSearch) & "%') " Else strSQL = strSQL & "WHERE parentID = 0 " End If strSQL = strSQL & "ORDER BY " & sortBy & " " & sortDir
'connect to the database
Set dbRS = Server.CreateObject("ADODB.Recordset") With dbRS .CursorLocation = 3 .CacheSize = C_dbPageSize .Open strSQL, C_dbConnect End With
If dbRS.EOF = False Then With dbRS .MoveFirst topicCount = CInt(.RecordCount) .PageSize = C_dbPageSize pageCount = CInt(.PageCount) .AbsolutePage = curPage End With Else topicCount = 0 pageCount = 1 End If
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.