Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Cant Delete via SQL string or Recordset.Delete
Old 12-05-2005, 06:12 AM Cant Delete via SQL string or Recordset.Delete
Skilled Talker

Posts: 95
Trades: 0
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
%>
higginbt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-05-2005, 07:38 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
have you tried
Code:
strSQL="DELETE FROM tDBAccess WHERE DBid = " & cint(DBid) & " AND ID = " & cint(FrmUser) & " ;"
Conn.Open strConnection
conn.execute(strSQL)
conn.close
Set Conn = Nothing
assuming DBid and ID are integers of course.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-05-2005, 10:04 AM
Skilled Talker

Posts: 95
Trades: 0
thanks it appears its not a problem with the code but the account that is accessing the database only having select permission not delete.
higginbt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Cant Delete via SQL string or Recordset.Delete
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11912 seconds with 12 queries