Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 27th, 2006, 01:51 PM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select COUNT(*)

Hei!

Why does this not display the total number of records in the recordset?

set objRsTelle=server.createobject("ADODB.Recordset")

    objRsTelle.open "select COUNT(*) from Innsjekk", kobling, adOpenForwardOnly, adLockReadonly, adcmdtext

        if objRsTelle.eof then

            totaltRegistrert = objRsTelle

            else

        End if

            objRsTelle.Close

            set objRsTelle = Nothing

Response.write totaltRegistrert

With regards
grstad

__________________
Internet has become favorable with that tool...thank you Tim Berners-Lee!
Reply With Quote
  #2 (permalink)  
Old April 28th, 2006, 03:16 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi grstad,

objRsTelle is a recordset, you need to get the value from a field within it.

Try this...
Code:
objRsTelle.open "select COUNT(*) AS recordcount from Innsjekk", kobling, adOpenForwardOnly, adLockReadonly, adcmdtext
totaltRegistrert = objRsTelle("recordcount").Value
HTH,

Chris

Reply With Quote
  #3 (permalink)  
Old April 28th, 2006, 07:50 AM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...thank you for your reply Chris Scott! (I will sooon try it out) But I wonder; it seems to be so many varied versions of all of the sql-query methods. Is it one standard Vb-script SQL which fit the ASP-tech?

Vennlig hilsen
grstad

Reply With Quote
  #4 (permalink)  
Old April 28th, 2006, 08:08 AM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have changed the code somewhat, and it gives a 0x800A0E7D


dim objRsMenner,AlleMann,m

set objRsMenner=server.createobject("ADODB.Recordset")

(line 71) objRsMenner.open "SELECT COUNT(1) as m FROM Produkt WHERE ProduktKjonn = '" & mann & "' GROUP BY ProduktKjonn"'", kobling, adOpenStatic, adLockReadonly, adcmdtext

            AlleMann = objRsMenner("m").Value

            objRsMenner.Close

            set objRsMenner = Nothing




Feiltype:
ADODB.Recordset (0x800A0E7D)
Tilkoblingen kan ikke brukes til å utføre denne operasjonen. Den er enten lukket eller ugyldig i denne sammenhengen.
/innsjekk/treff_yngre.asp, linje 71

Med vennlig hilsen
grstad

Reply With Quote
  #5 (permalink)  
Old April 28th, 2006, 08:26 AM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

... it does work, the variable no holds "0"!. But it is records in the db with the value like "mann"!?

Med vennlig hilsen
grstad

Reply With Quote
  #6 (permalink)  
Old April 28th, 2006, 11:01 AM
Friend of Wrox
 
Join Date: May 2005
Location: , , Norway.
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

... it seems that an answer can be;

objRsMenner.open "SELECT COUNT(*) AS m, ProduktKjonn
FROM Produkt GROUP BY ProduktKjonn
ORDER BY COUNT(*) DESC;",
kobling, adOpenForwardOnly, adLockReadonly, adcmdtext

            AlleMann = objRsMenner("m").value

It is only two different values in the field ProduktKjonn. Either it is "mann" or it is "kvinne". The "DESC" in the query then sort out "menn", and count it to "some value". But what if there was more than two diff values in the field ProduktKjonn, and I want some value between "m" and "k"?. The WHERE...conditions, how does I get it to work?

Does anyone have the answer?

Med hilsen
grstad :)

...som har det med å svare seg selv!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Count from multiple tables aspless SQL Language 1 January 30th, 2008 10:32 AM
How to get "SELECT COUNT(*)" return information? datagram ASP.NET 1.0 and 1.1 Basics 3 December 23rd, 2004 01:21 AM
SELECT COUNT as a ROW?? t0ny SQL Language 3 December 8th, 2004 05:31 AM
Select Where Greater Than Count dave.cody@accenture.com SQL Language 3 April 29th, 2004 05:14 AM
How to execute SELECT count(*) lxu Access 2 April 8th, 2004 08:16 AM



All times are GMT -4. The time now is 06:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.