Showing posts with label figure. Show all posts
Showing posts with label figure. Show all posts

Sunday, February 19, 2012

CountRows()

I've got a simple problem, but because this is my first report, I can't quite figure it out and it's driving me nuts!

I've got an ASP.NET web application with an .RDLC report. The report works fine, i.e. it renders data correctly. However, I cannot get the CountRows() function to work. I've got a cell in the group footer with the following:

=CountRows("grpBuyer")

And I'm getting the compiler error:

The value expression for the textbox XXXX has a scope parameter that is not valid...

"grpBuyer" is what is specified in the Grouping/Sorting property of the group header. I've also tried "TableRow2", which seems to be the name of the group header, but it yeilds the same compiler error.

Some please help!

Thanks, Alex

Hello Alex,

You have to pass group name (which by default is somewhat like "<objectname>_Group") to this function, you can get group name by right clicking on the object(table/matrix/list) and then click on "Group Tab" and there you will see all groups name for that object. You should pass exact name of Group, like i did =CountRows("list1_Details_Group") and it should work fine.

hope this will solve your problem.

Friday, February 17, 2012

Counting Result Set from SQL Query Before Fill()ing a DataSet

I need to display something like "Results x-y of z." The problem is, I can't figure out how to get the right value for z.

I am using SqlDataAdapter and Fill()ing a DataSet with subset x through y of the result set. How can I get the right value for z?

You are going to have to query the database to get the record number.

Select Count(OneOfYourFields) from YourTable.

You can command.executescalar to get the result

|||

Thank you for the reply.

I am using a Stored Procedure, so this makes things a bit more complicated. I know with MySQL you can use mysql_num_rows() to fetch the number of rows a query will return, without actually grabbing all the data from that query and pulling it onto the web server. Is there any similar functionality in C#/ASP.NET?

|||What ken means is that you need to run a count(*) query to retrieve the number of rows. ExecuteScalar will return the first record in the first row which is all you need since you only need the count. Then just display that number.|||I think I understood what Ken said. However, I am not just selecting from one table, I am executing a complicated Stored Procedure on multiple tables. How can I run a COUNT(*) on the Stored Procedure?|||

Hi,

As far as I know, we cannot run COUNT() on the result set of a stored procedure. The only way I think is to add some SELECT COUNT(*) for each table in the stored procedure and return the count as OUTPUT parameters.

counting problem...

Hi. I have a small problem that i just can't seem to figure out. I'm trying to generate a report for a case management system. The problem I am having is trying to exclude some of these results. Here is my query:

SELECT COUNT(DefendantCase.ProsAtty) AS CountOfProsAtty
FROM DefendantCase LEFT JOIN DefendantEventPros ON DefendantCase.VBKey=DefendantEventPros.VBKey
WHERE DefendantCase.StatusID=17 AND DefendantCase.ProsAtty=55
AND DefendantEventPros.EventDate BETWEEN DATEADD(DAY,-60,GETDATE()) AND GETDATE() AND DefendantEventPros.EventID=9

This query is trying to find the total amount of cases where the statusid=17, the prosatty=55, the date is between today and 60 days ago, and there is an eventid=9.

now, i'm not getting errors in the query itself; it's just that it's inflating the total number. If a case has more than one eventid=9, it will include that extra in the results. I do not want to include those in the results. Does anyone have any suggestions? Thanks!select count(ProsAtty) AS CountOfProsAtty
from DefendantCase
where StatusID=17
and ProsAtty=55
and EventID=9
and exists
( select 937
from DefendantEventPros
where VBKey = DefendantCase.VBKey
and EventDate
between dateadd(day,-60,getdate())
and getdate() )|||I hope I don't show up in that result set :)|||select count(ProsAtty) AS CountOfProsAtty
from DefendantCase
where StatusID=17
and ProsAtty=55
and EventID=9
and exists
( select 937
from DefendantEventPros
where VBKey = DefendantCase.VBKey
and EventDate
between dateadd(day,-60,getdate())
and getdate() )
thank you! that works perfectly!

Tuesday, February 14, 2012

Counting Consecutive days in SQL

I've been trying to figure out how to count the number of consecutive
days of entries in a table. the table stores data on number of minutes
exercised in a day for users of an exercise program:
ExerciseId int
UserId int
Minutes int
ExerciseDate datetime
I need to produce a list of users who exercised XX number of days in a
row. e.g. 60 consecutive days of exercise. Any ideas on how to do that?
I'm using SQL Server 2000.
ThanksVibroluxOn10@.gmail.com wrote:
> I've been trying to figure out how to count the number of consecutive
> days of entries in a table. the table stores data on number of minutes
> exercised in a day for users of an exercise program:
> ExerciseId int
> UserId int
> Minutes int
> ExerciseDate datetime
> I need to produce a list of users who exercised XX number of days in a
> row. e.g. 60 consecutive days of exercise. Any ideas on how to do that?
> I'm using SQL Server 2000.
> Thanks
>
http://www.aspfaq.com/show.asp?id=2519