|
Hi i'm trying to delete a record from a databse table. Its a simply record its not linked to any other information that will cause trouble.
I have used two forms to select the information, My first form allows a admin user to select a Database, THe second page shows a list of members who are allowed to access that table. From this page i want to add more members or DELETE current members.
My code displays a simple message at the moment for adding a user, when i press the delete button, at the moment it is displaying the information passed in from the form, and also displaying the surname of the user to be delete.(the surname is being read from the databse so i'm pretty sure my sql strings are working.
my problem is although my page runs and it doesnt come up with any errors the recors is not deleted. I''ve tried DELETE FROM and rcordset.Delete.
But none are actually being deleted. PLEASE HELP
'create an ADO connection and recordset
Set Conn = Server.CreateObject("ADODB.Connection")
Set RcrdSet = Server.CreateObject("ADODB.Recordset")
RcrdSet.CursorType = 2
RcrdSet.LockType = 4
dim DBid
dim FrmUser
'Request Data from the form.
DBid = Request.Form("hideDBid")
FrmUser =Request.Form("FuserList")
'Check which button is pressed if ADD then run this Code
if Request.Form("FBtnDBAccess") = "ADD" then Response.Write ("Hello ADD User") end if
'If Del Button was Pressed then Run this Code
if Request.Form("FBtnDBAccess") = "DEL" then
'Displays the data from the form
Response.Write ("DBID from form: " )
Response.Write (Dbid)
Response.Write ("<BR>")
Response.Write ("Record ID from Form: ")
Response.Write (FrmUser)
Response.Write ("<BR>")
'SQL Strings to select the data.
'strSQL="DELETE FROM tDBAccess WHERE DBid = 1 AND ID = 10"
strSQL="Select * FROM tDBAccess WHERE DBid = '" & (DBid) & "' AND ID = '" & (FrmUser) & "' "
'Open database Connection Only
Conn.Open strConnection
RcrdSet.Open strSQL,Conn
RcrdSet.Delete
RcrdSet.Update
'Displays the username from the database
Response.Write ("FROM DATABASE")
Response.Write RcrdSet("Username")
'Close Connnection and Recordset
RcrdSet.Close
Conn.Close
Set RcrdSet = Nothing
Set Conn = Nothing
end if
%>
|