Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Viewing records immediatly after deleting one. 1

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
I have a web page that shows a table view of records from my Access database. You enter the customer Acct # and the records appear. I have made it so that clicking on one of the records will delete it (after a confirmation box) from the database. I do this by submitting the value of the record to the page, and running a delete command on a recordset that contains only that record. I then close the recordset and open a new one that is used to list the records. On my test system this works fine, when you delete a record the table is immediatly updated. However, on my production server it doesn't. You have to refresh the page to get the correct listing. Here is my delete code. Please help if you can.

deletedValue = Request.Form("delValue")
if NOT deletedValue = "" then
set deleteSet = Server.CreateObject("ADODB.Recordset")
deleteString = "select * from tblSchools where cust_ID ='"&custid&"' AND SchoolName ='"&deletedValue&"'"
deleteSet.open deleteString, strConnect, adOpenDynamic, adLockOptimistic
deleteSet.Delete
deleteSet.Close
set deleteSet = Nothing
Response.Write deletedValue & " was deleted from the database."
end if
 
Try deleting the record w/o a recordset before opening the display one again.

To do this, you just need a DELETE statement rather than the SELECT that you have created. It might look like this:
Code:
'explicitly create a connection
dim con
set con = server.createObject("ADODB.Connection")
con.open strConnect

deletedValue = Request.Form("delValue") 
if NOT deletedValue = "" then 
   'build up your DELETE statement
   deleteString = "DELETE FROM tblSchools where cust_ID ='"&custid&"' AND SchoolName ='"&deletedValue&"'" 
   'execute the command on the database
   con.execute deleteString
   Response.Write deletedValue & " was deleted from the database." 
end if

and then open your display recordset, which will be minus the record you have deleted here.

:)
paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top