hello all friend's,
i'm a newbee to asp. it totally harder than PHP ;) . i'm facing trouble when try to delete records from a list..
i take the scripts from http://www.w3schools.com/ado/ado_delete.asp but i made the custom msaccess2002 database b'cause i had no nortwind.mdb database.
dbname = tes.mdb , tablename = tes. it fields are :
id = autonumber, primary key
name,email,skill = text
comment = memo
my scripts are consist of 2 asp page. they are : listdata.asp and demo_delete.asp
listdata.asp
---------------
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/inetpub/wwwroot/nwind/tes.mdb"
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM tes",conn
%>
<h2>List Database</h2>
<table border="1" width="100%">
<tr>
<%
for each x in rs.Fields
response.write("<th>" & ucase(x.name) & "</th>")
next
%>
</tr>
<% do until rs.EOF %>
<tr>
<form method="post" action="demo_delete.asp">
<%
for each x in rs.Fields
if x.name="id" then%>
<td>
<input type="submit" name="id" value="<%=x.value%>">
</td>
<%else%>
<td><%Response.Write(x.value)%></td>
<%end if
next
%>
</form>
<%rs.MoveNext%>
</tr>
<%
loop
conn.close
%>
</table>
</body>
</html>
------------------------------------------------------------------------------------------------------
demo_delete.asp
-----------------------
<html>
<body>
<h2>Delete Record</h2>
<%
'set conn=Server.CreateObject("ADODB.Connection")
'conn.Provider="Microsoft.Jet.OLEDB.4.0" -->cannot use this it will become error
'conn.Open "c:/inetpub/wwwroot/nwind/tes.mdb"
'Creating connection Object
set Conn=server.createobject("ADODB.Connection")
'Creating Recordset Object
set rs = Server.CreateObject("ADODB.Recordset")
'Initializing Provider String
connStr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("tes.mdb")
'Opening Connection to Database
Conn.open connStr
cid=Request.Form("id")
if Request.form("id")="" then
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM tes WHERE id='" & cid & "'",conn
%>
<form method="post" action="demo_delete.asp">
<table>
<%for each x in rs.Fields%>
<tr>
<td><%=x.name%></td>
<td><input name="<%=x.name%>" value="<%=x.value%>"></td>
<%next%>
</tr>
</table>
<br /><br />
<input type="submit" value="Delete record">
</form>
<%
else
sql="DELETE FROM tes"
sql=sql & " WHERE id='" & cid & "'"
on error resume next
conn.Execute sql
if err<>0 then
response.write("No update permissions!")
else
response.write("Record " & cid & " was deleted!")
end if
end if
conn.close
%>
</body>
</html>
------------------------------------------------------------------------------------------------------
when i clicked the id button number it shows the error :
No Update Permission
any comments will really help me , thank you so much :)