Slette en post fra database (acces)
HejJeg har følgenden script som jeg har downloadet og redigeret, men når jeg trykker på linket der skal slette en defineret post fra databasen så sker der intet. Den finder hvilken id posten som skal slette har, men den sletter den ikke.
Scriptet se lidt forkortet således ud:
<%
if action = "deleteentry" then
'Slet det valgte recordset ud fra angivet ID i url'en.
Conn.Execute "DELETE * FROM data WHERE id=" & Request.QueryString ("id") & ""
response.redirect("./?lang=" & lang)
end if
%>
<%
set rscount = nothing
dim strmessage,strname,stremail,strdatesend,strhomepage,strcountry,stremailoutput,strhomepageoutput
dim stricqoutput,strip,showall,strid,strsep,rsadmin
dim intpage,intreccount,intpagecount,strsql,strdsn,intnum
Set RsAdmin = Conn.Execute("SELECT * FROM admin")
intPage = Request("page")
If isNumeric(intPage) = False Or intPage < 1 Then
intPage = 1
End If
Set rs = Server.CreateObject("ADODB.RecordSet")
strSQL = "SELECT * FROM data ORDER BY id DESC"
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("\log\pag\DB\tagwalldb.mdb")
rs.Open strSQL, strDSN, 1
if rs.EOF then response.write book_empty
If Not (rs.BOF Or rs.EOF) Then
rs.PageSize = rsadmin("pagesize")
rs.AbsolutePage = intPage
intRecCount = rs.PageSize
intPageCount = rs.PageCount
Response.Write "<p><b>" & book_page & " " & intPage & " " & book_of & " " & intPageCount & "</b></p>"
Do While Not rs.EOF And intRecCount > 0
'Slut på kode.
strip = rs("ip")
strmessage = rs("message")
strname = rs("name")
stremail = rs("email")
strdatesend = rs("datesend")
strhomepage = rs("homepage")
strcountry = rs("country")
strid = rs("id")
<A NAME="<% = strid %>"></A>
<TABLE WIDTH="600" BORDER="0" CELLPADDING="5">
<TR>
<TD WIDTH="150" CLASS="header" background="graphic/table_bg.gif"><I>Info</I></TD>
<TD CLASS="header" background="graphic/table_bg.gif">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD class="header"><I><% = book_message %></I>
<% if admin = 1 then %>
<A HREF="?action=deleteentry&id=<% = strid %>">
<IMG SRC="Smilies/delete.gif" BORDER="0" WIDTH="9" HEIGHT="11" ALIGN="bottom" ALT="Remove"></A>
<% end if %>
</TD>
<% if rsadmin("quote") = 1 then %><TD ALIGN="right" class="header"><I><A HREF="addtag.asp?quote=<% = strid %>"><% = book_quote %></A></I></TD><% end if %>
</TR>
</TABLE>
</TD>
</TR>
%>
<%
intRecCount = intRecCount - 1
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
%>