Home | Advertising Info104 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Monday, August 21, 2017  

  Active InfoActive Info  Display List of Info MembersMemberlist  Search The InfoSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Database Issues
 PowerASP Code Help Area : Classic ASP - Database Issues
Subject Info: Return count of rows affected from MySQL A d d  -  P o s tAdd P o s t
Author
Message << Prev Info | Next Info >>
ThePriest
Newbie
Newbie
Avatar

Joined: February/16/2005
Location: South Africa
Online Status: Offline
Info: 2
Added: 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 info by ThePriest
 
firas_TheGeek
Newbie
Newbie
Avatar

Joined: May/27/2006
Location: Oman
Online Status: Offline
Info: 28
Added: 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 info by firas_TheGeek Visit firas_TheGeek's Homepage
 
niels666
Newbie
Newbie


Joined: April/16/2007
Online Status: Offline
Info: 1
Added: 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 info by niels666
 

If you wish to make a comment to this info you must first login
If you are not already registered you must first register

  A d d  -  P o s tAdd P o s t
Printable version Printable version

Info Jump
You cannot add new info in this area
You cannot add to info in this area
You cannot delete your info in this area
You cannot edit your info in this area
You cannot create polls in this area
You cannot vote in polls in this area

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright 1998 - 2017 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.

vbscript active server pages ASP vbscript SQL database informix oracle SQL Server Perl CGI Delphi PHP source code code sample samples program CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com