Click here to Skip to main content
15,896,313 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a report(Database SQL2005, For report use Crystalreport, App-VB.net) with many matrices. Basically what I want to do is display a message such as "No History within Date Range Selected" if there is no data on the report (all of the matrices return no data).


Is there a way to determine if the report is returning no data and show a textbox message in that case?
Posted

1 solution

There are 3 potential reasons for no data in crystalreport:
1) uppercase/lowercase inconsistency
To correct this problem just use formula like this: UpperCase({Customer.Name}) = "BOB"

2) unwanted spaces appear in selection formula
For example formula like this: "Mr. " in {Customer.Title} will not find any matches because of "Mr." (without of space) in the title.

3) uncorrect dates formats
For example: on the sql server dates are presented as: "MM/dd/yyyy", but on the local comupter: "yyyy/MM/dd"
Change the date format on your sql server or on the local computer or use SET DATEFORMAT ymd; command in your sql question.

So... first check the formulas!

If solution above is not helpful, ask your database for count of records before showing crystalreport or use stored procedure (recommended) with the body like this:
SQL
IF NOT EXISTS( Field1, Field2, Field3
               FROM [DatabaseName].[dbo].[TableName1]
               WHERE (Field4 BETWEEN @dFrom AND @dTo ))
BEGIN
     SELECT 'No History within Date Range Selected' AS [CommentField]
ELSE
     SELECT Field1, Field2, Field3
     FROM [DatabaseName].[dbo].[TableName1]
     WHERE (Field4 BETWEEN @dFrom AND @dTo)
 
Share this answer
 
v2
Comments
RaviRanjanKr 20-Nov-11 9:43am    
My 5+
Maciej Los 21-Nov-11 14:36pm    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900