Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 6th, 2006, 09:27 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default how many records

I want to know how many records have been affected by a sql statement
I use dr.RecordsAffected.ToString
but it does not respond!
here is the code:
Dim strSQL3 as string
strSQL3 = "SELECT * from test where e=1"
    objConnection = New SQLConnection(strConnection)
    cmd = New SQLCommand(strSQL3, objConnection)
    objConnection.Open()
    dr = cmd.ExecuteReader()

 If dr.HasRows = False Then
          strNewMsgCount=0
 End If

Do while (dr.Read())
strTotal=dr.RecordsAffected.ToString
Loop

dr.Close()

 
Old September 6th, 2006, 08:02 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This can be done with a stored procedure and defining an output parameter like so

CREATE PROCEDURE [someprocedure]
(
  @Rows int output
)

SET @Rows = @@ROWCOUNT

then just deal with it in code.

this post may help you as well:
http://www.dotnet247.com/247reference/msgs/5/25190.aspx

"The one language all programmers understand is profanity."
 
Old September 7th, 2006, 02:52 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in updating records & finding records naveed77 VB Databases Basics 1 January 16th, 2007 12:12 PM
problem in updating records & finding records naveed77 VB How-To 1 January 16th, 2007 12:10 PM
What are "records"? sterlingsilver10289 C++ Programming 1 May 11th, 2006 04:11 PM
Repeating Records Nicky_uk Classic ASP Databases 7 February 2nd, 2005 05:41 PM
more than 2 records with the same ID crmpicco Classic ASP Databases 7 January 27th, 2005 07:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.