sql = "SELECT COUNT (b.Aar) AS Tal FROM Billeder b WHERE b.Aar = " & Rs("Id") & ";" Set RsTael = RsTael.Execute(Sql) If Not RsTael.EOF Then Response.Write "<tr><td><p><b><a href=billeder.asp?aar=" & Rs("Id") & ">" & Rs("Aar") & "</a> " & RsTael("Tal") & "</b></td></tr>" Else End If
RS.MoveNext Loop Else Response.Write "<tr><td><p><br><br><br><b>No match was found from this query!!</b><br><br></td></tr>" End If RsTael.Close Set RsTael = Nothing RS.Close Set RS = Nothing %>
<% Set Conn = Server.CreateObject("ADODB.Connection") DBPath = "DBQ=" & server.mappath("mindb.mdb") Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & DBPath sql = "SELECT * FROM Aarstal;" Set Rs = Conn.Execute(Sql) If Not Rs.EOF Then Do While Not RS.EOF
sql2 = "SELECT COUNT(Aar) AS Tal FROM Billeder WHERE Aar = " & Rs("Id") & ";" Set RsTael = Conn.Execute(Sql) If Not RsTael.EOF Then Response.Write "<tr><td><p><b><a href=billeder.asp?aar=" & Rs("Id") & ">" & Rs("Aar") & "</a> " & RsTael("Tal") & "</b></td></tr>" Else End If
RS.MoveNext Loop Else Response.Write "<tr><td><p><br><br><br><b>No match was found from this query!!</b><br><br></td></tr>" End If RsTael.Close Set RsTael = Nothing RS.Close Set RS = Nothing %>
Grunden til den fejl er at der jo på et eller andet tidspunkt vil komme et årstal som der ikke tilhører nogen billeder, og denne stump kode prøver altså at udskrive noget som ikke er der.
sql = "SELECT * FROM Aarstal;" Set Rs = Conn.Execute(Sql) If Not (RS.BOF OR Rs.EOF) Then Do While Not RS.EOF
sql2 = "SELECT COUNT(Aar) AS Tal FROM Billeder WHERE Aar = " & Rs("Id") & ";" Set RsTael = Conn.Execute(Sql) If Not (RsTael.BOF OR RsTael.EOF) Then Response.Write "<tr><td><p><b><a href=billeder.asp?aar=" & Rs("Id") & ">" & Rs("Aar") & "</a> " & RsTael("Tal") & "</b></td></tr>" Else End If
RS.MoveNext Loop Else Response.Write "<tr><td><p><br><br><br><b>No match was found from this query!!</b><br><br></td></tr>" 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.