473,382 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

execute sql count statement in asp

In ASP page, if we want to retrive the number of rows in database: should we
use recordset object? Since this is not update, insert, delete, or select
statement

sqlStmt = "SELECT COUNT(*) from table1;"
Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.open sqlStmt, strConnect

But how do we can the value?

Jul 19 '05 #1
1 5111

"Matt" <ma*******@hotmail.com> wrote in message
news:uM**************@TK2MSFTNGP09.phx.gbl...
In ASP page, if we want to retrive the number of rows in database: should we use recordset object? Since this is not update, insert, delete, or select
statement
Yes, you should, since you need to retrieve a value. But it'd be like so:

sqlStmt = "SELECT COUNT(*) from table1;"
Set oADO = Server.CreateObject("ADODB.Connection")
oADO.Open strConnect
Set rsCount = oADO.Execute(sqlStmt)
iCount = rsCount.Fields.Item(0).Value
rsCount.Close : Set rsCount = Nothing
oADO.Close : Set oADO = Nothing

Response.Write "The count is " & iCount
Just be aware of issues with counting * as opposed to a specific column that
will always have a value, ie. the PK. See here, at least.
http://www.aspfaq.com/show.asp?id=2073

Ray at home


sqlStmt = "SELECT COUNT(*) from table1;"
Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.open sqlStmt, strConnect

But how do we can the value?

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ravi | last post by:
Hi All, I am trying to execute a select statement using the DBI module of perl in a for loop. I am getting a strange behaviour, the select statement is excuting correctly only for the last element...
4
by: Jill Graham | last post by:
Hi, I'm using an access database and found following problem : I have a table X with 2 records : record 1 & record 2. I execute following procedure with 2 steps : 1. The procedure deletes...
4
by: finlma | last post by:
I'm trying to run an EXECUTE IMMEDIATE within a PL/SQL if loop but it doesn't work for me. I'm trying to create a column conditionally but it doesn't work. It fails because there are apostrophes...
3
by: Agoston Bejo | last post by:
I am looking for the PL/SQL equivalent of the VBScript Exec and/or Eval functions, i.e. I want to be able to dynamically create a statement, then execute it in the current PL/SQL context, e.g. ...
6
by: Doohan W. | last post by:
Hi, I'm now working with DB2, and I can't find out how to execute the contents of a string Statement, without using a Java/... procedure, only using SQL statements. I know that some SQBDs such...
18
by: Darryl Kerkeslager | last post by:
When I open an ADO Recordset, I close it. However, it seems that there may be some difference in this manner of opening a Recordset: Dim rL As ADODB.Recordset Set rL = New ADODB.Recordset ...
5
by: John Grandy | last post by:
Is there any way in C# to mimic the T-SQL EXEC() command (which runs a string as if it was in-line T-SQL code) ?
5
by: alingsjtu | last post by:
Hello, every body. When execute dynamic generated multiple OPENQUERY statements (which linkes to DB2) in SQLServer, I always got SQL1040N The maximum number of applications is already connected...
1
by: lakon15 | last post by:
Dear all, I'll try to convert from SQL server Store Procedure to DB2 Store Procedure. I've make SP under DB2 like this CREATE PROCEDURE GetSearchedRecords (pKeyWords VARCHAR(1000), ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.