ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 29th, 2009, 09:12 AM
bazzanoid bazzanoid is offline
Contributing User
Click here for more information.
 
Join Date: Nov 2004
Posts: 153 bazzanoid User rank is Corporal (100 - 500 Reputation Level)bazzanoid User rank is Corporal (100 - 500 Reputation Level)bazzanoid User rank is Corporal (100 - 500 Reputation Level)bazzanoid User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 17 h 33 m 57 sec
Reputation Power: 7
ASP.Net/VB.Net - COUNTing records?

Afternoon all,

First time i've ever used a COUNT command as part of a select statement, and i have no idea how to use the information!!!

I assumed (i feel a bit wrongly) that the resulting number would be stored in the variable as specified, e.g.

Code:
ProductTotal = tobjConn.Execute("SELECT count(*) FROM Prices")


and then to call the variable was just a case of using this:

Code:
<%= ProductTotal(0) %>


I'm guessing this is entirely wrong from start to finish since i get this error:

Quote:
Item cannot be found in the collection corresponding to the requested name or ordinal


I know it's really simple, but i've never used a COUNT before, so have no clue......... suggestions welcome and needed!!!

Thanks!

Reply With Quote
  #2  
Old October 29th, 2009, 06:10 PM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
that's not ASP.NET, it's VBScript.

learn about OleDbConnection, OleDbCommand and OleDbDataReader
and I'm sure you'll be able to accomplish what you need easily.

Reply With Quote
  #3  
Old October 30th, 2009, 05:13 AM
bazzanoid bazzanoid is offline
Contributing User
Click here for more information.
 
Join Date: Nov 2004
Posts: 153 bazzanoid User rank is Corporal (100 - 500 Reputation Level)bazzanoid User rank is Corporal (100 - 500 Reputation Level)bazzanoid User rank is Corporal (100 - 500 Reputation Level)bazzanoid User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 17 h 33 m 57 sec
Reputation Power: 7
Ah yes, posted in the wrong forum!! I'd be grateful if you could shift it to the classic ASP forum for me....

I'll have a read up on ole in the meantime...

Reply With Quote
  #4  
Old October 30th, 2009, 03:38 PM
rclark's Avatar
rclark rclark is offline
I do .NET for a living
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Sep 2003
Location: Florida
Posts: 1,435 rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level)rclark User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 20 h 37 m 13 sec
Reputation Power: 157
Code:
Why <%= ProductTotal(0) %> vs. <%= ProductTotal %> ?


Isn't ProductTotal just an integer?
__________________
Roger (.NET MCP)

Reply With Quote
  #5  
Old October 30th, 2009, 06:31 PM
richyrich's Avatar
richyrich richyrich is offline
Contributing User
ASP Free Specialist (4000 - 4499 posts)
 
Join Date: Jun 2004
Location: Somewhere only we know...
Posts: 4,220 richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)richyrich User rank is General 7th Grade (Above 100000 Reputation Level)  Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 130723 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 1 Week 3 Days 14 h 27 m 36 sec
Reputation Power: 1441
Can't say I've ever executed a query like that.

My tried and tested method is something like:-
Code:
strsql = "SELECT COUNT(*) As noRecords FROM Prices"
Set rs = Server.CreateObject("ADODB.RecordSet")
conn.open()
rs.open strsql,conn

ProductTotal = rs("noRecords")

rs.close
conn.close
set rs = nothing
set conn = nothing

Hope that helps
__________________
Policy Check

I'd rather have a full bottle in front of me, than a full frontal lobotomy...

Reply With Quote
  #6  
Old November 1st, 2009, 04:01 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
--moved to the classic ASP forum

in theory, it's possible to read from recordset using the field index instead
of the field name so can't see any obvious reason for the code to fail.

try changing the code to:
Code:
Dim ProductTotal, nRecordCount
Set ProductTotal = tobjConn.Execute("SELECT count(*) As MyCount FROM Prices")
nRecordCount = CLng(ProductTotal("MyCount"))
ProductTotal.Close

then use the variable nRecordCount in order to show/use the count.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > ASP.Net/VB.Net - COUNTing records?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek