Home | Advertising Info5 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Sunday, April 28, 2024  

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Database Issues
 PowerASP Code Help Area : Classic ASP - Database Issues
Subject Topic: Return count of rows affected from MySQL Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
ThePriest
Newbie
Newbie
Avatar

Joined: February/16/2005
Location: South Africa
Online Status: Offline
Posts: 2
Posted: February/16/2005 at 7:29am | IP Logged Quote ThePriest

Using ASP to MySQL to delete rows.
I would like to return a count of the rows affected. So far as I understand  it should be possible with DELETE, SELECT etc statements. All my tries failed so I would like to know how the following code might be modiefied to get it.

objStr = "DELETE FROM maildata WHERE (Mail='"&Request.Form("Email")&"' AND MailRole='CC');"
   
    Set objConn = Server.CreateObject("ADODB.Connection")
    Set objRS = Server.CreateObject("ADODB.Recordset")

    objConn.Open "DSN=DBName-MySQL"

    objConn.Execute(objStr)

    objConn.close
    Set objConn = Nothing :    Set objRS = Nothing

All input is welcome
Back to Top View ThePriest's Profile Search for other posts by ThePriest
 
firas_TheGeek
Newbie
Newbie
Avatar

Joined: May/27/2006
Location: Oman
Online Status: Offline
Posts: 28
Posted: May/27/2006 at 9:56am | IP Logged Quote firas_TheGeek

the code to do so:

dim intDeletedRecords
intDeletedRecords=0

objStr = "DELETE FROM maildata WHERE (Mail='"&Request.Form("Email")&"' AND MailRole='CC');"
   
    Set objConn = Server.CreateObject("ADODB.Connection")
    Set objRS = Server.CreateObject("ADODB.Recordset")

    objConn.Open "DSN=DBName-MySQL"

    objrs.open objStr,objConn,2,3

do until objrs.eof
intDeletedRecords=intDeletedRecords+1
objrs.delete
objrs.update
objrs.movenext
loop
response.write "The Number of deleted records is:" & intDeletedRecords


    objConn.close
    Set objConn = Nothing :    Set objRS = Nothing

 

Hope this helps

Best Regards



__________________
Firas S Assaad (TheGeek)
firas489@gmail.com
0096892166434
http://firas-thegeek.blogspot.com
Back to Top View firas_TheGeek's Profile Search for other posts by firas_TheGeek Visit firas_TheGeek's Homepage
 
niels666
Newbie
Newbie


Joined: April/16/2007
Online Status: Offline
Posts: 1
Posted: April/16/2007 at 5:56am | IP Logged Quote niels666

Hi ThePriest,

I was looking for the same this, ThePriest, and there is a very very simple way to do this.

for your code:

objStr = "DELETE FROM maildata WHERE (Mail='"&Request.Form("Email")&"' AND MailRole='CC');"

Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")

objConn.Open "DSN=DBName-MySQL"

objConn.Execute(objStr, intAffectedRows)

response.write "Rows affected: " & intAffectedRows

objConn.close
Set objConn = Nothing
Set objRS = Nothing

As you see: just add an extra parameter to the execute method.

Back to Top View niels666's Profile Search for other posts by niels666
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2024 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages asp source code database MS SQL MS Access .mdb adovbs.inc cookies calendar codes sql commands scripts asp programming tutorials iis web server components CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com