christrinder
02-14-2003, 10:01 AM
As a fairly newbie to ASP, I have started creating a forum (similar to this) as a learning exercise/project. I want users to be able to delete their post, but where they delete the first post in a thread, it then deletes all related posts. I've got the code below, but it only deletes the first one of the replies. I have tried adding a loop statement where not objRSreplies.EOF, but I get a error message saying that the operation cannot be completed whilst the object is closed? I need your help please!
<%
Dim deleteid
deleteid = request.querystring("id")
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("******.mdb")
strSQLthread = "SELECT id, posttitle, posttime, postdate, post, postby, threadid from forum where id = "& deleteid &""
Set objRSthread = adoCon.Execute(strSQLthread)
If objRSthread("postby") <> session("forumuserid") then
response.redirect "unauthorised.asp"
End If
%>
<%
Set objRSthread = Server.CreateObject("ADODB.Recordset")
strSQLthread = "SELECT id, posttitle, posttime, postdate, post, postby, threadid from forum where id = "& deleteid &""
objRSthread.CursorType = 2
objRSthread.LockType = 3
objRSthread.Open strSQLthread, adoCon
objRSthread.Delete
%>
<%
Set objRSreplies = Server.CreateObject("ADODB.Recordset")
strSQLreplies = "SELECT id, posttitle, posttime, postdate, post, postby, threadid from forum where threadid = "& deleteid &""
objRSreplies.CursorType = 2
objRSreplies.LockType = 3
objRSreplies.Open strSQLreplies, adoCon
objRSreplies.Delete
objRSreplies.MoveNext
objRSreplies.Update
objRSreplies.Close
Set objRSreplies = Nothing
%>
<%
Dim deleteid
deleteid = request.querystring("id")
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("******.mdb")
strSQLthread = "SELECT id, posttitle, posttime, postdate, post, postby, threadid from forum where id = "& deleteid &""
Set objRSthread = adoCon.Execute(strSQLthread)
If objRSthread("postby") <> session("forumuserid") then
response.redirect "unauthorised.asp"
End If
%>
<%
Set objRSthread = Server.CreateObject("ADODB.Recordset")
strSQLthread = "SELECT id, posttitle, posttime, postdate, post, postby, threadid from forum where id = "& deleteid &""
objRSthread.CursorType = 2
objRSthread.LockType = 3
objRSthread.Open strSQLthread, adoCon
objRSthread.Delete
%>
<%
Set objRSreplies = Server.CreateObject("ADODB.Recordset")
strSQLreplies = "SELECT id, posttitle, posttime, postdate, post, postby, threadid from forum where threadid = "& deleteid &""
objRSreplies.CursorType = 2
objRSreplies.LockType = 3
objRSreplies.Open strSQLreplies, adoCon
objRSreplies.Delete
objRSreplies.MoveNext
objRSreplies.Update
objRSreplies.Close
Set objRSreplies = Nothing
%>