Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 August 12th, 2004, 03:35 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataView - Can you count a distinct category?


Hello
I know SQL more than ASP.NET.
In SQL, you can use DISTINCT and COUNT to get number of items of a distinct category.

I can do this in SQL but I want to do in the DataView. Is this possible??
I wanted to count the distinct category in DataSet by DataView rather than to use 5 Stored Procedures for each category of the DataSet.

I thought about passing parameters to Stored Procedure but I thought if this is possible in DataView than it is easier.

All suggestions are welcome.
Thanks.

 
Old August 12th, 2004, 07:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Yes. Another way to do Count would be to create a label and a Function and do this:

lblCount.Text = countDays()

Private Function countDays()
        Dim strConn As String = ConfigurationSettings.AppSettings("dbLogs")
        Dim objConn As New OleDbConnection(strConn)

        Dim strSQL As String = "SELECT Count(thedate) FROM tableName"

        Dim objCommand As New OleDbCommand(strSQL, objConn)

        Dim sResult As String
        objConn.Open()
        sResult = CType(objCommand.ExecuteScalar(), String)
        objConn.Close()

        Return sResult
End Function

 
Old August 12th, 2004, 07:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Not using the DataView directly, that I know of. You have to use a SQL query.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Distinct Jonas Access 2 August 14th, 2006 01:03 PM
count distinct values Chris Cash XSLT 3 June 8th, 2006 04:55 PM
count distinct nodes alexshiell XSLT 2 January 27th, 2005 11:19 AM
sql to return distinct count pbgurl Access VBA 2 October 29th, 2004 06:29 AM
COUNT ON SELECT DISTINCT stmt savoym SQL Language 7 August 28th, 2003 07:58 AM





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