Pagina "elenco.asp"
codice:
<html>
<head>
<title>GESTIONE NEWS</title>
</head>
<%
' Connessione database
Set conn = Server.CreateObject("ADODB.Connection")
sql = "SELECT * FROM news ORDER BY data DESC"
dsnpath = "DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)}; "
dsnpath = dsnpath & "DBQ=" & Server.MapPath("database.mdb")
conn.open dsnpath
%>
<body>
<div align="center">
<center>
<table border="1" cellpadding="4" width="100%" cellspacing="0" height="58">
<tr>
<td width="18" valign="middle" align="center" height="29" bordercolor="#000080">
</td>
<td width="185" height="29" bordercolor="#000080">
<p align="center"><font size="2" face="Verdana" color="#000080">Titolo</font></td>
<td width="611" height="29" bordercolor="#000080">
<p align="center"><font size="2" face="Verdana" color="#000080">Testo del documento</font></td>
</tr>
<%
Set rec = Server.CreateObject("ADODB.Recordset")
Set Rec=Conn.Execute(SQL)
While Not rec.EOF
%>
<tr>
<td width="18" valign="top" align="justify" height="1" bordercolor="#000080" >
<font size="1"><a href="del.asp?cod=<%=rec("id")%>">
cancella</a></font></td>
<td width="184" height="1" valign="top" align="justify" bordercolor="#000080" ><font size="1" face="Verdana"><%=rec("Titolo")%></font></td>
<td width="611" height="1" valign="top" align="justify" bordercolor="#000080" ><font size="1" face="Verdana"><%=rec("descrizione")%></font></td>
<% rec.MoveNext
Wend
rec.close%>
</center>
</table>
</div>
</body>
</html>
Pagina "del.asp"
codice:
<%
' Connessione database
Set conn = Server.CreateObject("ADODB.Connection")
dsnpath = "DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)}; "
dsnpath = dsnpath & "DBQ=" & Server.MapPath("database.mdb")
conn.open dsnpath
%>
<%
cod=Request.Querystring("cod")
SQL="DELETE FROM news WHERE id="&cod
Conn.Execute(SQL)
Response.Redirect "elenco.asp"
%>
Prova!