ASP Recordset

How can I delete a record from a recordset?

Page 1 of 1

7 Replies - 3996 Views - Last Post: 28 November 2001 - 12:37 PM Rate Topic: -----

#1 Mist  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 10-April 01

ASP Recordset

Posted 19 October 2001 - 04:24 PM

I have isolated the record I want to delete in a recordset (Don't ask how, that code is messy, and I'm working on cleaning it up and streamlining it a bit more).

Now I want to delete the said record. Is there any easy way to do this (By issuing some command to the recordset object)?

I already know you can use the ADODB.Connection object's Execute-method & and SQL-statement to delete the record, but that'll increase the workload on the server.

Thanks in advance for any advice.

-Mist


Is This A Good Question/Topic? 0
  • +

Replies To: ASP Recordset

#2 Mist  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 10-April 01

Re: ASP Recordset

Posted 20 October 2001 - 12:55 PM

Hmm...

I found out how. It was really fairly simple...

You just type 'RS.Delete' when you are at the correct record. (But remember to check that the record is indeed the one you want to delete. I learned that the hard way...)

-Mist

Was This Post Helpful? 0
  • +
  • -

#3 Quentin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 26-November 01

Re: ASP Recordset

Posted 26 November 2001 - 11:56 AM

learned that the hard way? uhh.... ;)

i was shocked finding out that rs.delete works without rs.update needed.... dammit :)

if you have more than one record selected (e.g. all entries with name 'Quentin' in it), you can delete them as shown here:

do while not rs.eof
 rs.delete
 rs.movenext
loop

please don't forget to include the rs.movenext.... i don't know how many times i produced code without movenext ehehe :) bad luck...

kind regards
quentin

Was This Post Helpful? 0
  • +
  • -

#4 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: ASP Recordset

Posted 26 November 2001 - 02:34 PM

just out of curiosity, why would you need to delete records from the recordset? why wouldn't you refine your query instead to not include those records?
Was This Post Helpful? 0
  • +
  • -

#5 Mist  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 10-April 01

Re: ASP Recordset

Posted 26 November 2001 - 10:06 PM

We want to delete stuff from a recordset, because when we delete it from the recordset, it doesn't only delete from the recordset, but from the entire database. That's the clue ;)

-Mist

Was This Post Helpful? 0
  • +
  • -

#6 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: ASP Recordset

Posted 27 November 2001 - 07:09 AM

oh yes, of course. I'm not used to thinking of recordsets in that way, so that didn't occur to me. Even so, why not use a delete query? I guess it would save you a trip to the db in some instances, but I don't think I've ever had a situation where I needed to do that. *ponder*
Was This Post Helpful? 0
  • +
  • -

#7 Mist  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 10-April 01

Re: ASP Recordset

Posted 27 November 2001 - 08:23 AM

Mainly because you can make exception code if the record you need to delete isn't there... That's why. If you run a simple DELETE-command, you risk the page throwing up a pile of, ermh, well, something, instead of progressing along nicely and showing a user-friendly error message...
Was This Post Helpful? 0
  • +
  • -

#8 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: ASP Recordset

Posted 28 November 2001 - 12:37 PM

oh ok, that works. :)

I wonder why I've never come across that yet. I think that whenever I'm deleting records, I *know* that they're there so I don't have to have it check (ie: I generally am deleting a record that has been retrieved already by that file, so it must exist).

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1