Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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 April 21st, 2006, 01:31 PM
Authorized User
 
Join Date: Apr 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display count of rows

I am trying to count the numbers of rows for the name column from a database table(Test) and display it on a page.
Can you pls help.I am also trying to link the number so that everytime,when the database gets updated the row count number automatically changes.

 
Old April 21st, 2006, 02:22 PM
Authorized User
 
Join Date: Apr 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am doing this in C#

 
Old April 21st, 2006, 04:29 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Open a window into your DB (data adapter, or whatever), and use the SQL

    SELECT COUNT(NAME)
    FROM MY_TABLE

You could do something simple like this with a command object’s .ExecuteScalar() function.


To get your app to update, the resource-economical way to do this is with an OnUpdate (or AfterUpdate, whatever) trigger in the database that then "tickles" your app. If the DB can receive the address of a function, and then call that function using the address, that would be the ticket.

Outside a database environment, this would be a callback process.



A far less efficient way is to go “inspect” the DB on a timed basis.
 
Old April 21st, 2006, 06:23 PM
Authorized User
 
Join Date: Apr 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am looking for the code which will help me to show the total count of rows without Datagrid or Repeater. And ExecuteScalar() does not work with C#. Pls help

 
Old April 23rd, 2006, 08:22 AM
Authorized User
 
Join Date: Apr 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ExecuteScalar does works is c#...

Object obj = cmd.ExecuteScalar();
long result = Convert.ToInt64(obj);

cmd is of type command object set it with your query and connection

 
Old April 24th, 2006, 11:25 AM
Authorized User
 
Join Date: Apr 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your help.

 
Old April 25th, 2006, 03:35 PM
Authorized User
 
Join Date: Apr 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No prob

 
Old May 5th, 2006, 04:13 AM
Authorized User
 
Join Date: Apr 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I see.

:)¡¶
 Â¡Â¶Â¡Â¶ No pains, no gains.
¡¶¡¶¡¶





Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieve everything AND count rows in one hit crmpicco MySQL 5 January 20th, 2006 06:02 AM
count of rows ashokparchuri ADO.NET 3 April 19th, 2005 11:19 AM
count the number of rows in the table crmpicco Javascript How-To 4 February 2nd, 2005 12:58 AM
count child table rows melvik C# 6 January 25th, 2004 01:39 AM





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