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;
}
}
}
}