Click here to Skip to main content
15,905,232 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m not able to find error.
output comes as blank page.

code is written as under.


Button click code :
VB
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Session("rptname") = "Report"
    Response.Redirect("m_protfolio_as_on.aspx")
End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
    Session("rptname") = "Report2"
    Response.Redirect("m_protfolio_as_on.aspx")
End Sub



Reportviewer code :

VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
<pre lang="vb">GenReport(Session("rptname"))

   End Sub



SQL
Public Sub GenReport(ByVal rptName As String)
       ReportViewer1.LocalReport.ReportPath = ""
       ReportViewer1.LocalReport.Refresh()
       Dim myDataSet As New DataSet
       Dim mvSQl As String
       Dim cn As New SqlConnection
       'cn.ConnectionString = "Data Source=windows;Initial Catalog=WTAuto;username =Integrated Security=false"
       cn.ConnectionString = "data source='ADMINN';initial catalog=wtauto;password='abc';persist security info=True;user id='sa'"
       cn.Open()

       If rptName = "Report" Then
           mvSQl = " SELECT Client.c_name, MTransaction.folioNo AS foliono, Scheme.s_name, SUM(MTransaction.unit) AS Unit, ISNULL((SELECT nav_Value FROM NAV WHERE(s_code = Scheme.s_code) AND (nav_Date =(SELECT MAX(nav_Date) AS Expr1 FROM NAV WHERE(nav_Date <= '30/Aug/2010') AND (s_code = Scheme.s_code)))), 0) AS Expr5, Scheme.Nature, GroupMaster.H_name FROM MTransaction WITH (readuncommitted) INNER JOIN GroupMaster INNER JOIN Client ON GroupMaster.c_code = Client.c_code ON MTransaction.c_code = Client.c_code INNER JOIN Scheme ON MTransaction.s_code = Scheme.s_code LEFT OUTER JOIN Branch ON MTransaction.Branch = Branch.Branch AND Client.CompanyName = Branch.CompanyName WHERE(MTransaction.TDate <= '30/Aug/2010') AND (GroupMaster.H_code = '00000000A1') AND (Client.CompanyName = 'Oraculo Advisory Pvt Ltd') GROUP BY GroupMaster.H_name, Client.c_name, Client.c_code, Scheme.Nature, Scheme.s_name, Scheme.s_code, MTransaction.folioNo HAVING(SUM(MTransaction.unit) > 0)ORDER BY GroupMaster.H_name, Scheme.Nature, Scheme.s_name, foliono"
       Else
           mvSQl = " SELECT Client.c_name, MTransaction.folioNo AS foliono, Scheme.s_name, SUM(MTransaction.unit) AS Unit, ISNULL((SELECT nav_Value FROM NAV WHERE(s_code = Scheme.s_code) AND (nav_Date =(SELECT MAX(nav_Date) AS Expr1 FROM NAV WHERE(nav_Date <= '30/Aug/2010') AND (s_code = Scheme.s_code)))), 0) AS Expr5, Scheme.Nature, GroupMaster.H_name FROM MTransaction WITH (readuncommitted) INNER JOIN GroupMaster INNER JOIN Client ON GroupMaster.c_code = Client.c_code ON MTransaction.c_code = Client.c_code INNER JOIN Scheme ON MTransaction.s_code = Scheme.s_code LEFT OUTER JOIN Branch ON MTransaction.Branch = Branch.Branch AND Client.CompanyName = Branch.CompanyName WHERE(MTransaction.TDate <= '30/Aug/2010') AND (GroupMaster.H_code = '00000000A1') AND (Client.CompanyName = 'Oraculo Advisory Pvt Ltd') GROUP BY GroupMaster.H_name, Client.c_name, Client.c_code, Scheme.Nature, Scheme.s_name, Scheme.s_code, MTransaction.folioNo HAVING(SUM(MTransaction.unit) > 0)ORDER BY GroupMaster.H_name, Scheme.Nature, Scheme.s_name, foliono"
       End If

       Dim myAdapter As SqlDataAdapter = New SqlDataAdapter(mvSQl, cn)
       myAdapter.Fill(myDataSet, 0)
       Dim RD As ReportDataSource
       If myDataSet.Tables(0).Rows.Count > 0 Then
           If rptName = "Report" Then
               RD = New ReportDataSource("DataSet1_DataTable1", myDataSet.Tables(0))
           Else
               RD = New ReportDataSource("DataSet2_DataTable1", myDataSet.Tables(0))
           End If

           ReportViewer1.LocalReport.DataSources.Clear()
           ReportViewer1.LocalReport.DataSources.Add(RD)
           If rptName = "Report" Then
               ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report.rdlc")
           Else
               ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report2.rdlc")
           End If


           ReportViewer1.ShowPrintButton = True
           ReportViewer1.LocalReport.Refresh()
       End If
   End Sub


Posted
Comments
Sandeep Mewara 7-May-11 7:44am    
1. Is the SQL query correct and returning data? Did you checked it by directly running in the DB?
2. Did you debug and see all goes well?
Honey Jagyasi 9-May-11 1:01am    
yes i debug all the things properly & it all goes well even the same query when i compile in database it fetches data properly.

everything goes well but at time of displaying data it shows blank page.i m getting all data in thier objects but still it gives blank page.
Honey Jagyasi 9-May-11 1:01am    
yes i debug all the things properly & it all goes well even the same query when i compile in database it fetches data properly.

everything goes well but at time of displaying data it shows blank page.i m getting all data in thier objects but still it gives blank page.

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