|
 |
access_asp thread: Deleting a record in Access-database
Message #1 by "Peter Eldh" <fireh@t...> on Mon, 5 Aug 2002 03:17:36
|
|
Hi all!
I have a problem when trying to delete a record in an Access-database.
I can add, view and change records, but I get an error when deeting.
Hope to get som help here!
---------------------------------------------------------------------
The code I'm using is:
<!--#include file="check_login.asp" -->
<!-- #include virtual="/orebro/medlemmar/skadekort/adovbs.inc" -->
<%
ID=Request.QueryString("ID")
SET db=Server.CreateObject("ADODB.Connection")
db.Open "driver={Microsoft Access Driver (*.mdb)};dbq="&Server.MapPath
("/orebro/medlemmar/databas/2002.mdb")
SET rs=db.Execute("SELECT * FROM Skadekort WHERE ID LIKE ID")
rs.Delete
rs.Close
db.Close
%>
---------------------------------------------------------------------
The error I recieve is:
ADODB.Recordset (0x800A0CB3)
Object or provider is not capable of performing requested operation.
/orebro/medlemmar/skadekort/delete2.asp, line 8
---------------------------------------------------------------------
Thank you for your help!
// Peter
Message #2 by "Ken Schaefer" <ken@a...> on Mon, 5 Aug 2002 12:12:18 +1000
|
|
a) You are opening a recordset with the default locktype (adLockReadOnly),
which does not support deletes
b) If you want to delete records from the table, why on earth are you
creating a huge recordset to hold all the records?!?
<%
strSQL = _
"DELETE FROM Table1 WHERE ID = 1"
objConn.Execute strSQL, lngRecsAffected, adCmdText+adExecuteNoRecords
Response.Write(lnRecsAffected & " record(s) where deleted."
%>
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Peter Eldh" <fireh@t...>
Subject: [access_asp] Deleting a record in Access-database
: Hi all!
:
: I have a problem when trying to delete a record in an Access-database.
: I can add, view and change records, but I get an error when deeting.
:
: Hope to get som help here!
:
: ---------------------------------------------------------------------
:
: The code I'm using is:
:
: <!--#include file="check_login.asp" -->
: <!-- #include virtual="/orebro/medlemmar/skadekort/adovbs.inc" -->
: <%
: ID=Request.QueryString("ID")
: SET db=Server.CreateObject("ADODB.Connection")
: db.Open "driver={Microsoft Access Driver (*.mdb)};dbq="&Server.MapPath
: ("/orebro/medlemmar/databas/2002.mdb")
: SET rs=db.Execute("SELECT * FROM Skadekort WHERE ID LIKE ID")
: rs.Delete
: rs.Close
: db.Close
: %>
:
: ---------------------------------------------------------------------
:
: The error I recieve is:
:
: ADODB.Recordset (0x800A0CB3)
: Object or provider is not capable of performing requested operation.
: /orebro/medlemmar/skadekort/delete2.asp, line 8
:
: ---------------------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #3 by "Peter Eldh" <fireh@t...> on Mon, 5 Aug 2002 23:12:45
|
|
Hi!
Now it works, thank you very much!
// Peter
|
|
 |