Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 21st, 2006, 01:31 PM
Authorized User
 
Join Date: Apr 2006
Location: , , .
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.

  #2 (permalink)  
Old April 21st, 2006, 02:22 PM
Authorized User
 
Join Date: Apr 2006
Location: , , .
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am doing this in C#

  #3 (permalink)  
Old April 21st, 2006, 04:29 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
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.
  #4 (permalink)  
Old April 21st, 2006, 06:23 PM
Authorized User
 
Join Date: Apr 2006
Location: , , .
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

  #5 (permalink)  
Old April 23rd, 2006, 08:22 AM
Authorized User
 
Join Date: Apr 2006
Location: , , .
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

  #6 (permalink)  
Old April 24th, 2006, 11:25 AM
Authorized User
 
Join Date: Apr 2006
Location: , , .
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your help.

  #7 (permalink)  
Old April 25th, 2006, 03:35 PM
Authorized User
 
Join Date: Apr 2006
Location: , , .
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No prob

  #8 (permalink)  
Old May 5th, 2006, 04:13 AM
Authorized User
 
Join Date: Apr 2006
Location: Dalian, LiaoNing, China.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I see.

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


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
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



All times are GMT -4. The time now is 10:45 PM.


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