Forum  General Visual ...  How do I...?  Report Viewer
Previous Previous
 
Next Next
New Post 6/28/2011 8:50 PM
Unresolved
  dbranger
118 posts
5th Level Poster


Report Viewer 

I'm still have trouble with the ReportViewer

 I have tried now on a second computer with just a simple report of drawing a box, line and texbox with Hello World in it. I have no data bindings and have added the aproperate resorces and modified the web.config file with the handler and still nothing. Just a blank page. I did the same thing in winforms and no problems

Any Ideas

 

 

 

 

 

 
New Post 6/29/2011 12:33 AM
  JamesC
1221 posts
www.redcastle.co.uk
1st Level Poster




Re: Report Viewer 
Modified By JamesC  on 6/29/2011 3:33:36 AM)

hi there

I have never used the reportViewer bt if you have only just added & registered the control, have you also tried uppering the PrivateVersion number of you project? (you'll find the setting in the web.config or in the project properties general tab

cheers james

 
New Post 6/29/2011 12:49 AM
  Ewans
815 posts
1st Level Poster




Re: Report Viewer 
Modified By Ewans  on 6/29/2011 3:53:03 AM)

Hi dbranger

How you use report viewer depends on which version of visual studio you are using.

If you are using VS 2008 getting report viewer to work is quite straight forward.

It is a little more tricky if you are using VS2010.

If so you must have the following in your web config

 

 

<system.web>

<httpRuntime maxRequestLength="100000" requestValidationMode="2.0" />

<httpHandlers>

<add verb="*" path="*.ashx" type="Gizmox.WebGUI.Server.Router,Gizmox.WebGUI.Server,Version=4.0.5701.0,Culture=neutral,PublicKeyToken=3de6eb684226c24d" />

<add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, &#xD;&#xA; Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

</httpHandlers>

There are various posts in the knowledge base that will help with how to display the reports eg

http://www.visualwebgui.com/Developers/KB/tabid/654/article/how_to_use_the_report_viewer_control_to_access_a_reporting_services_server/Default.aspx?category=CodeB.Code4.Code1

Hope this helps

Ewan

 
New Post 6/29/2011 9:37 AM
  dbranger
118 posts
5th Level Poster


Re: Report Viewer 

Thanks Ewan & James

I did try your suggestions but was unsuccessful.

I'm going to try it again on another machine. I noticed the link you provided suggested that you need to have a connection to reporting services. As it does operate correctly in my WinForms app I'm assuming that should also be the case in my Webforms app. My test app is not actually connecting to any tables. It’s just simply putting controls on the Report Viewer. My thoughts are that if it works in its most simple form I can build on it.

Indecently the report viewer does come up. It just doesn’t display anything. If I single step though the code it steps completely through, just no result

 

 
New Post 6/29/2011 12:34 PM
  Ewans
815 posts
1st Level Poster




Re: Report Viewer 
Modified By Ewans  on 6/30/2011 2:50:58 AM)

Hi dbranger

You only need a connection to Reporting services if your reports are hosted on a separate reporting services server.

If you use local reports they just need including in your application.

I usually use Visual Studio 2008 to develop my reports as server side reports as I can more easily develop and test them  (.rdl). Reports that are created this way can be run as local reports provided you provide the data for them. Visual Studio 2010 displays reports that are created in version 2008 (which is the version of report writer 2010 uses just to add to the confusion) .

Below shows the code to display reports created this way. Note the hosted page load event is key to the report displaying at all.

Hope this helps

Ewan

 

#region Using
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
 
using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using Gizmox.WebGUI.Reporting;
using Microsoft.Reporting.WebForms;
using Gizmox.WebGUI.Common.Interfaces;
 
#endregion
 
namespace Accounts
{
    public partial class Reports : UserControl
    {
        //private Uri uriRS = new Uri (ConfigurationManager.ConnectionStrings["rslink"].ConnectionString);
        private SqlConnection dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString);
        private Boolean bitReset = false;
        private string strReportPath = "";
        private List<ReportParameter> paramList;
        private String strRptName;
        private String strRptPeriod;
        private String strRptMonth;
 
        public Reports()
        {
            InitializeComponent();           
        }
 
        public void DisplayReport(String strReport, String strPeriod, String strMonth)
        {
            bitReset = true;
            strRptName = strReport;
            strRptPeriod = strPeriod;
            strRptMonth = strMonth;
            this.CAreports.Update();
        }
 
        private void CAreports_ReportRefresh(object sender, CancelEventArgs e)
        {
 
        }
 
        private void CAreports_Sort(object sender, SortEventArgs e)
        {
 
        }
 
        private void CAreports_Toggle(object sender, CancelEventArgs e)
        {
 
        }
 
        private void CAreports_HostedPageLoad(object sender, Gizmox.WebGUI.Forms.Hosts.AspPageEventArgs e)
        {
            if (bitReset)
            {
                this.CAreports.Reset();
 
                SqlDataAdapter daDSN = new SqlDataAdapter("select DSN, DSNqry from Reports R inner join dbo.ReportDSN DS on IDX = Didx Where Report = '" + strRptName + "'", dbconn);
                //strRptName = MyReport.rdl
                strReportPath = Context.Server.MapPath("~\\Reports\\" + strRptName);
               
                this.CAreports.LocalReport.ReportPath = strReportPath;
                //Build and populate Report DataSources
                DataTable dtDSN = new DataTable();
                daDSN.Fill(dtDSN);
 
                this.CAreports.LocalReport.DataSources.Clear();
 
                foreach (DataRow row in dtDSN.Rows)
                {
                    string strDSN = row[0].ToString();
                    string strDSNqry = row[1].ToString();
 
                    SqlCommand scReportData = new SqlCommand(strDSNqry, dbconn);
                    scReportData.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter daReportData = new SqlDataAdapter(scReportData);
                    dbconn.Open();
                    SqlCommandBuilder.DeriveParameters(scReportData);
                    dbconn.Close();
 
                    scReportData.Parameters[1].Value = strRptPeriod;
                   
 
                    DataTable ReportData = new DataTable();
                    daReportData.Fill(ReportData);
                    this.CAreports.LocalReport.DataSources.Add(new ReportDataSource(strDSN, ReportData));
 
                }
 
                //Prepare report parameters.
                ReportParameterInfoCollection Params = this.CAreports.LocalReport.GetParameters();
 
                paramList = new List<ReportParameter>();
 
                if (strRptName.Substring(0, 6) == "Annual")
                {
                    paramList.Add(new ReportParameter("year", strRptPeriod.Substring(0, 4), false));
                }
               
                else
                {
                    paramList.Add(new ReportParameter("period", strRptPeriod, false));
                    paramList.Add(new ReportParameter("mth", strRptMonth, false));
                }
 
                this.CAreports.ProcessingMode = ProcessingMode.Local;
                this.CAreports.LocalReport.ReportPath = strReportPath;
                this.CAreports.LocalReport.SetParameters(paramList);
                bitReset = false;
            }
           
        }
    }
 
}

 

 

 
Previous Previous
 
Next Next
  Forum  General Visual ...  How do I...?  Report Viewer