Generate HTML Report using Stored Procedure in ASP.Net

Last Reply on Aug 02, 2014 05:50 AM By Azim

Posted on Jul 31, 2014 03:00 AM

Mr.Mudassar

I have the following SP is working fine. I have dumped the data into temp table and bind with Report viewer.
But based on performance level, it is not compatible coz lots of user using. We have decided that export in html format

But I do not know how to do this. Pls advice

Thank you

Maideen

My SP

 

 

GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


ALTER PROCEDURE [dbo].[Z_usp_Circ_Head_AVGIssue_Paid]
	
	@YearStart VARCHAR(4),
    @YearEnd VARCHAR(4),
	@Language VARCHAR(20),
	@Type VARCHAR(20),
	@Platform VARCHAR(100),
	@Category VARCHAR(50),
	@MainArea VARCHAR(100)
	--@Mode VARCHAR(50)
AS
BEGIN
 declare @where varchar(1500), @sSQL VARCHAR(2000),@yearint INT,@i INT, @vYEAR VARCHAR(1000), @vTemp INT, 
        @calYear VARCHAR(10)
set @where = ''

 IF (@Language <> 'All') BEGIN
	IF (@where <> '') select @where = @where + ' and '
   select @where = @where + 'LANGUAGE = ''' + ltrim(rtrim(@Language )) + ''''
 END

 IF (@Type <> 'All') BEGIN
	IF (@where <> '') select @where = @where + ' and '
   select @where = @where + 'TYPE = ''' + ltrim(rtrim(@Type )) + ''''
 END

 IF (@Platform <> 'All') BEGIN
	IF (@where <> '') select @where = @where + ' and '
   select @where = @where + 'PLATFORM = ''' + ltrim(rtrim(@Platform )) + ''''
 END

 IF (@Category <> 'All') BEGIN
	IF (@where <> '') select @where = @where + ' and '
   select @where = @where + 'CATEGORY = ''' + ltrim(rtrim(@Category )) + ''''
 END

 IF (@MainArea <> 'All') BEGIN
	IF (@where <> '') select @where = @where + ' and '
   select @where = @where + 'MAINAREA = ''' + ltrim(rtrim(@MainArea )) + ''''
 END

 SET @vYEAR = ''

SET @yearint = CAST(@YearEnd AS INT) - CAST(@YearStart AS INT)
SET @yearint = @yearint + 1
SET @i = 0

WHILE (@i < @yearint)
BEGIN
	SET @vTemp = @YearStart + @i

	--SET @vYEAR = @vYEAR + '[' + CAST(@vTemp AS VARCHAR(4)) + '06' + ']'
	--SET @vYEAR = @vYEAR + ',' + '[' + CAST(@vTemp AS VARCHAR(4)) + '12' + ']'
	SET @vYEAR = @vYEAR + '[' + 'JUN-' + CAST(@vTemp AS VARCHAR(4)) + ']'
	SET @vYEAR = @vYEAR + ',' + '[' + 'DEC-' + CAST(@vTemp AS VARCHAR(4)) + ']'

	IF (@i<@yearint-1)
	BEGIN
		SET @vYEAR = @vYEAR + ','
	END
	SET @i = @i + 1
END



Set @sSQL = 'SELECT *  FROM 
(SELECT 
 MEMBER,[LANGUAGE],[TYPE],[PLATFORM],[AVGIssue_Paid],CATEGORY,MAINAREA,REMARKS,MY 
 FROM Z_tbl_Circulation_Head '

IF @where <> ''
BEGIN
	Set @sSQL = @sSQL + ' Where ' + @where
END

Set @sSQL = @sSQL + ' ) TableYearNo
pivot (Sum(AVGIssue_Paid) for my IN ('+@vYEAR+')) pivotTable'

--PRINT @ssql
INSERT INTO [dbo].[AVG_Paid]
EXEC(@sSQL)


 END

 

Posted on Jul 31, 2014 03:00 AM

Get the data in DataTable and then you can generate either HTML or PDF reports