Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Counting .... uhh.. someone help please
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 4

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 09 March 2002 :  16:17:07  Show Profile
On my site I have a list of the DVDs that I own. Right now I have to manually edit the page if I buy a new DVD and want to add it so I added the DVD's table from my "inventory" database into my test forums' database.

I used the Smilies MOD by Stimmy to be able to add new DVD's which works fine except that I can't edit the info nor delete them (I'm getting new code for this all soon).

What I'm looking for is something to count the DVD's that are in the DB. So actually it'd count the records. Then that number could be shown on the top of the page.

The table is called FORUM_DVD and I'm ordering the DVD's by ID.
Could anyone give me the basic code to count how many records there are in the table?

Thanks.



http://www.frutzle.com

Snitz Exchange | Do's and Dont's

OneWayMule
Dev. Team Member & Support Moderator

Austria
4969 Posts

Posted - 09 March 2002 :  16:32:05  Show Profile  Visit OneWayMule's Homepage  Send OneWayMule an ICQ Message
strSql = "SELECT COUNT(ID) AS DVD_COUNT FROM FORUM_DVD"

I think this should work.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 09 March 2002 :  16:33:20  Show Profile  Visit Nathan's Homepage
strSql = "SELECT count(ID) AS cnt FROM DVD_TABLE"
set rs = Conn.execute strSql
numberOfDVDs = rs("cnt")

  Nathan Bales - Romans 15:13
----------------------------------

Snitz Exchange | Do's and Dont's
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 09 March 2002 :  16:33:49  Show Profile  Visit Nathan's Homepage
I've been beaten !

  Nathan Bales - Romans 15:13
----------------------------------

Snitz Exchange | Do's and Dont's
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 09 March 2002 :  17:25:13  Show Profile
Thanks guys!

I'll show the result as soon as I have it all working.



http://www.frutzle.com

Snitz Exchange | Do's and Dont's
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 09 March 2002 :  19:10:09  Show Profile
Since I'm too late, all I can offer is

"There are 3 kinds of people, those who can count and those who can't."

======
Doug G
======
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 09 March 2002 :  19:16:13  Show Profile
I can count... a calculator is easier though



http://www.frutzle.com

Snitz Exchange | Do's and Dont's
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 09 March 2002 :  20:07:01  Show Profile
quote:

Since I'm too late, all I can offer is

"There are 3 kinds of people, those who can count and those who can't."

======
Doug G
======



Roland ... read that ^ again!

Doug ... ... funny guy

Nikkol
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 09 March 2002 :  20:14:33  Show Profile  Visit Nathan's Homepage
Hehe, get out your calculator and add up those types Frutz

  Nathan Bales - Romans 15:13
----------------------------------

Snitz Exchange | Do's and Dont's
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 09 March 2002 :  20:30:55  Show Profile
Hey I didn't use a calculator and it's 2:30am... (can't remember what time I posted that and don't know the time diff either).

<edit> Okay, it was 1:15am when I posted that reply lol [b]</edit>



http://www.frutzle.com

Snitz Exchange | Do's and Dont's

Edited by - FrutZle on 09 March 2002 20:33:31
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 13 March 2002 :  18:07:35  Show Profile
I'll be heading off in a minute or so, but if I don't post this now I'll forget and I won't be able to find this thread again once I think about it again (okay, enough intro ).

Anyway, I tried this:

<% strSql = "SELECT COUNT(ID) AS DVD_COUNT FROM " & strTablePrefix & "DVD" %>
This is the list of DVD's that I own (currently <% =DVD_COUNT %> titles*).


but it doesn't show anything. I know I'm doing something wrong that's completely basic, but I can't figure it out.
I also tried Nathan's solution, but that didn't help either (also, no result shown). I know the DB connection works as a couple lines later I have all records showing and sorted by ID...



http://www.frutzle.com

Snitz Exchange | Do's and Dont's
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 13 March 2002 :  18:40:55  Show Profile
There needs to be a bit more code (I haven't tested this)

Your SQL Statement is assigning a column name DVD_COUNT to the results of the COUNT() function. This isn't a ASP variable name, so you need to execute the sql to return a recordset, then get the value out of the recordset.

<% strSql = "SELECT COUNT(ID) AS DVD_COUNT FROM " & strTablePrefix & "DVD"
set rstTest = myConn.execute(strSql)
DVD_COUNT = rstTest("DVD_COUNT") %>

This is the list of DVD's that I own (currently <% =DVD_COUNT %> titles*).

I just actually read the above posts, this is exactly what Nathan said earlier and should work.

======
Doug G
======

Edited by - Doug G on 13 March 2002 18:43:47
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 14 March 2002 :  13:56:10  Show Profile
Using the last suggestion I get this error:

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/newfrutzle/dvds/default.asp, line 19

I've put a .txt version of that file online at http://www.frutzle.com/temp/dvd_count_prob.txt
Maybe the counting would be better as a sub which is then called at the top of the page?



http://www.frutzle.com

Snitz Exchange | Do's and Dont's
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 14 March 2002 :  14:13:30  Show Profile
Maybe this has something to do with it:

This is the list of DVD's that I own (currently <% =APPLE %> titles*).


Nikkol
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 14 March 2002 :  14:22:39  Show Profile
quote:

Maybe this has something to do with it:

This is the list of DVD's that I own (currently <% =APPLE %> titles*).


Nikkol



Yeah, my bad... I put that in there to test something. lol
Forgot to take it out again I'm blonde you know



http://www.frutzle.com

Snitz Exchange | Do's and Dont's
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 14 March 2002 :  14:25:32  Show Profile
I was gonna tell you to try BANANA instead.

Nikkol
Go to Top of Page
Page: of 4 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.29 seconds. Powered By: Snitz Forums 2000 Version 3.4.07