Sql = "Select * from news order by dato DESC"
Jeg har et gæstebogs ligende asp, men her vil jeg KUN hente den sidste post i min database....Jeg har fundet ud af at ved en gæstebog bruger man :
Sql = "Select * from T_gaestebog order by dato DESC"
Men jeg skal jo ikke bruge * her... Men derimod noget andet!! Den skal KUN tage den ENE post i min database.. Nemlig den sidste!!!!
Herunder er hele min kode :
Set Rs = Server.CreateObject("ADODB.Connection")
DBPath = "DBQ=" & server.mappath("gbdb.mdb")
Rs.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & DBPath
If Request.Servervariables("Content_Length") > 0 then
Sql = "Insert into t_gaestebog (Fra, Dato, email, http, Tekst) values(''" & Request("Fra") & "'',''" & Now() & "'',''" & Request("email") & "'',''" & Request("webside") & "'',''" & Request("Besked") & "'')"
Rs.Execute(Sql)
Response.Write strongfont & "Tak for det...</font></Strong><br><br>"
end if
If "" = Request.QueryString("Mode") then
Sql = "Select * from T_gaestebog order by dato DESC"
Set Record = Rs.Execute(Sql)
response.write "<html><head><title>Gæstebog</title></head><body>"
response.write strongfont & "Gæstebogen</font></strong>"
response.write "<table border=''0'' width=''500''>"
Do While Not Record.EOF
response.write "<tr><td bgcolor=''" & linecolor & "'' colspan=''2''></td></tr>"
response.write "<tr><td width=''0'' align=''right''>" & font & "Navn:</td>"
response.write "<td width=''100%''>" & font & Record("Fra") & "</td></tr>"
response.write "<tr><td width=''0'' align=''right''>" & font & "Twat:</td>"
response.write "<td width=''100%''>" & font & Record("Twat") & "</td></tr>"
response.write "<tr><td width=''0'' align=''right''>" & font & "E-Mail:</td>"
response.write "<td width=''100%''>" & font & "<a href=''mailto:" & Record("Email") & "''>" & Record("Email") & "</a></td></tr>"
response.write "<tr><td width=''0'' align=''right''>" & font & "Webside:</td>"
response.write "<td width=''100%''>" & font & "<a href=''" & Record("http") & "''>" & Record("http") & "</a></td></tr>"
response.write "<tr><td width=''0'' align=''right''>" & font & "Dato:</td>"
response.write "<td width=''100%''>" & font & Record("dato") &"</td></tr>"
response.write "<tr><td width=''0'' align=''right'' valign=''top''>" & font & "Besked:</td>"
response.write "<td width=''100%''>" & font & Record("Tekst") & "</td></tr>"
Record.MoveNext
Loop
response.write "</table>"
Record.Close
RS.Close
end if
If "add" = Request.QueryString("Mode") then
response.write strongfont & "Skriv i gæstebogen</strong>"
response.write "<form method=''POST'' action=''" & Request.ServerVariables("SCRIPT_NAME") & "''>"
response.write "<div align=''left''><table border=''0'' width=''50%''>"
response.write "<tr><td valign=''top'' align=''right'' colspan=''2'' bgcolor=''" & linecolor & "''></td></tr>"
response.write "<tr><td valign=''top'' align=''right''>" & font & "Navn:</td>"
response.write "<td valign=''top''>" & font & "<input type=''text'' name=''Fra'' size=''40''></td></tr>"
response.write "<tr><td valign=''top'' align=''right''>" & font & "Twat:</td>"
response.write "<td valign=''top''>" & font & "<input type=''text'' name=''Twat'' size=''40''></td></tr>"
response.write "<tr><td valign=''top'' align=''right''>" & font & "E-Mail:</td>"
response.write "<td valign=''top''>" & font & "<input type=''text'' name=''email'' size=''40''></td></tr>"
response.write "<tr><td valign=''top'' align=''right''>" & font & "Webside:</td>"
response.write "<td valign=''top''>" & font & "<input type=''text'' name=''webside'' size=''40'' value=''http://''></td></tr>"
response.write "<tr><td valign=''top'' align=''right''>" & font & "Besked:</td>"
response.write "<td valign=''top''>" & font & "<textarea rows=''5'' name=''Besked'' cols=''40''></textarea></td></tr>"
response.write "<tr><td colspan=''2'' valign=''top'' align=''right''><div align=''center''><center><p>" & font & "<input type=''submit'' value=''Send'' name=''B1''> <input type=''reset'' value=''Slet'' name=''B2''></td></tr>"
response.write "<tr align=''center''><td colspan=''2'' valign=''top'' align=''right'' bgcolor=''" & linecolor & "''></td></tr></table>"
response.write "</form></body></html>"
end if