Slet fra database
Hej.Jeg har følgende kode, som kommer med følgende fejl:
deleteComment.asp file
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression 'ID='13216'.
/u/DeleteComment.asp, line 14
Har gedet lidt rundt i "nyID" og "ID", så det kan være her fejlen ligger.
sletcomment.asp:
<%
Dim Conn, Rs, sql
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/db/mydb.mdb")
sql= "SELECT * FROM seneste;"
Rs.Open sql, Conn
Response.Write "<FORM name='Delete' method='post' action='DeleteComment.asp'>"
Response.Write "<table border=1 cellspacing=0>"
Response.Write "<tr>"&"<td colspan='3' align='center'>"&"Select a comment to delete and click delete"&"</td>"&"</tr>"
Response.Write "<tr>"&"<th align='center' colspan='2'>"&"Name"&"</th>"&"<th align='center'>"&"Comment"&"</th>"&"</tr>"
Do While not Rs.EOF
Response.Write ("<tr>")
Response.Write ("<td>"&"<input type='radio' name='nyID' value="&Rs("id")&">"&"</td>")
Response.Write ("<td>"&Rs("beskrivelse")&"</td>")
Response.Write ("<td>"&Rs("powerpoint")&"</td>")
Response.Write ("</tr>")
Rs.MoveNext
Loop
Response.Write("<tr>"&"<td colspan='3' align='center'>"&"<input type ='submit' name='submit' value='Delete' onClick='return validate();'>"&"</td>"&"</tr>")
Response.Write "</table>"
Response.Write "</form>"
Rs.Close
Set Rs = Nothing
Set Conn = Nothing
%>
DeleteComment.asp:
<%
Dim nyID
nyID = Request.Form("nyID")
if nyID="" then
Response.Write "You did not select a name to delete!"
Else
Dim Conn
Dim Rs
Dim sql
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/db/mydb.mdb")
sql= "Delete * FROM seneste WHERE ID='" & nyID
Rs.Open sql, Conn
Conn.Close
Set Conn = Nothing
Response.Write "Successfully Deleted"
End If
%>
Håber der er nogen der kan hjælpe mig.
Mvh.
Henrik