Kan ikke selv finde rundt i koden mere :-(
Hej,Jeg er ved at lave så den udskriver kl. ??:?? hvis det er i dag og "I går kl ??:??" hvis sidste indlæg var i går og bare datoen hvis de er ældre.
Jeg vil lige fremhæve jeg er selvlært i asp og derfor har mange mangler endnu, derfor vil en færdig kode med ændringen kun være brugbart for mig.
Koden hvor fejlen er i er denne:
Set formatDate = myConn.Execute(strSQL)
datoDB = FormatDateTime(datoTid,2)
If (formatDate.BOF Or formatDate.EOF) Then
dtmFormatDate = "Ingen indlæg"
elseif CStr(datoDB) = Cstr(Date) then
dtmFormatDate = "kl. " & formatDateTime("FormTime")
elseif CStr(datoDB) = CStr(DateAdd("d", -1, Date)) then
dtmFormatDate = "Igår kl. " & FormatDateTime(datoTid,4)
else
dtmFormatDate = FormatDateTime(datoTid,2) & " " & FormatDateTime(datoTid,4)
End If
Her kan det hele ses:
<%
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("test.mdb")
Function DBFix(tempString)
tempString = Replace(Trim(tempString), "'", "''")
tempString = Replace(tempString, "|", "")
DBFix = tempString
End Function
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open strDSN
strSQL = "SELECT * FROM Forums"
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
Do While Not rs.EOF
mygroup = rs("mygroup") ' find ud af hvilken gruppe det er
if mygroup <> mylastgroup then ' er den forskellig fra sidst ??
%>
<TR>
<TD BGCOLOR="#F4F6F6" STYLE="border-bottom: 1px solid #000000;"><BR> <B><%=mygroup%></B></TD>
<TD BGCOLOR="#F4F6F6" ALIGN="center" STYLE="border-bottom: 1px solid #000000;"><BR><B>Indlæg</B></TD>
<TD BGCOLOR="#F4F6F6" ALIGN="center" STYLE="border-bottom: 1px solid #000000;"><BR><B>Seneste</B></TD>
</TR>
<%
end if
mylastgroup = mygroup ' sidste gruppe sættes lig nuværende
strSQL = "SELECT *, Format$([date],'dd-mm-yyyy') AS FormDate, Format$([date],'hh:mm') AS FormTime FROM Entries WHERE (ForumID =" & rs("Id") & ") ORDER BY ID DESC"
Set formatDate = myConn.Execute(strSQL)
datoDB = FormatDateTime(datoTid,2)
If (formatDate.BOF Or formatDate.EOF) Then
dtmFormatDate = "Ingen indlæg"
elseif CStr(datoDB) = Cstr(Date) then
dtmFormatDate = "kl. " & formatDateTime("FormTime")
elseif CStr(datoDB) = CStr(DateAdd("d", -1, Date)) then
dtmFormatDate = "Igår kl. " & FormatDateTime(datoTid,4)
else
dtmFormatDate = FormatDateTime(datoTid,2) & " " & FormatDateTime(datoTid,4)
End If
strSQL = "SELECT Count(*) AS ItemCount FROM Entries Where (ForumID = " & rs("Id") & ")"
Set recordCount = myConn.Execute(strSQL)
response.write "<tr><td STYLE=""border-bottom: 1px dotted #E2E2E2;""><b><IMG SRC=""../images/pilmap.gif"" BORDER=""0"" WIDTH=""15"" HEIGHT=""12"" ALIGN=""bottom"" ALT=""""><a href=""kategori.asp?forumid=" & rs("ID") & """>" & rs("Forum") & "</a></b></td>"
response.write "<td ALIGN=center STYLE=""border-bottom: 1px dotted #E2E2E2;"">" & recordCount("ItemCount") & "</td>"
response.write "<td ALIGN=center STYLE=""border-bottom: 1px dotted #E2E2E2;"">" & dtmFormatDate & "</td></tr>"
rs.MoveNext
Loop
End If
myConn.Close
Set myConn = Nothing
%>
Den laver ingen scripft-fejl med ovenstående kode men skriver 30-12-1899 00:00 ved alle steder hvor der er indlæg.
