T
Tyranno.Lex
I am using Visual Studio .NET 2003 and have successfully deployed a
commercial web application written in C# and ASP.NET. I am now wanting
to add reporting using Crystal Reports and am having a devil of a time
doing this.
The problem is that my application uses an encapsulated data tier for
accessing the database vs. accessing it directly via the client tier.
However, EVERY example that I have ever seen for creating a Crystal
Report at runtime assumes that one is connecting directly to the
database from the web application code. This is, as we all know, a bad
design. For reasons varying from security to scalability to ease of
programming and support, the database should be exposed via a separate
object library.
Unfortunately, I cannot find a single example where this architecture
is used in conjunction with Crystal Reports. I did find some
information on MSDN where this is done with Visual Studio 2005...with
that version, examples are given where the report wizard can point
straight to the dll exposing the data tier. This is exactly what I
need - however, I have yet to succesfully port this application to
2005. In the meantime, can someone please give me a hint as how I
might dynamically create a report directly from a dataset that I have
created on the fly from the data objects?
Below is the code for the type of thing I am trying to do. A function
creates the dataset that is to be used (I have left that code off as it
is not important) and then another function initializes the report
using this dataset. The report comes up when the page is loaded, but
it is blank. This doesn't surprise me as I have not defined the
fields, etc. that need to be shown on the report (since VS 2003 doesn't
support designing a report while pointing to a data tier.)
How do I do this? TIA for any leads...I think all I need is a push in
the correct direction.
Regards,
T. Lex
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
try
{
LoadDataFromDatabase(false);
}
catch(Exception ex)
{
System.Diagnostics.Debug.Write("GetTopHundred: " + ex.Message);
}
ConfigureCrystalReports();
}
private void ConfigureCrystalReports()
{
string reportPath = Server.MapPath("CrystalReport1.rpt");
rankingDSet = (DataSet) Cache["AppData"];
rankingDView = new DataView(rankingDSet.Tables[0]);
rptStockRankings = new ReportDocument();
rptStockRankings.Load(reportPath);
rptStockRankings.SetDataSource(rankingDSet);
ReportViewer_Rankings.ReportSource=rptStockRankings;
ReportViewer_Rankings.DataBind();
}
commercial web application written in C# and ASP.NET. I am now wanting
to add reporting using Crystal Reports and am having a devil of a time
doing this.
The problem is that my application uses an encapsulated data tier for
accessing the database vs. accessing it directly via the client tier.
However, EVERY example that I have ever seen for creating a Crystal
Report at runtime assumes that one is connecting directly to the
database from the web application code. This is, as we all know, a bad
design. For reasons varying from security to scalability to ease of
programming and support, the database should be exposed via a separate
object library.
Unfortunately, I cannot find a single example where this architecture
is used in conjunction with Crystal Reports. I did find some
information on MSDN where this is done with Visual Studio 2005...with
that version, examples are given where the report wizard can point
straight to the dll exposing the data tier. This is exactly what I
need - however, I have yet to succesfully port this application to
2005. In the meantime, can someone please give me a hint as how I
might dynamically create a report directly from a dataset that I have
created on the fly from the data objects?
Below is the code for the type of thing I am trying to do. A function
creates the dataset that is to be used (I have left that code off as it
is not important) and then another function initializes the report
using this dataset. The report comes up when the page is loaded, but
it is blank. This doesn't surprise me as I have not defined the
fields, etc. that need to be shown on the report (since VS 2003 doesn't
support designing a report while pointing to a data tier.)
How do I do this? TIA for any leads...I think all I need is a push in
the correct direction.
Regards,
T. Lex
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
try
{
LoadDataFromDatabase(false);
}
catch(Exception ex)
{
System.Diagnostics.Debug.Write("GetTopHundred: " + ex.Message);
}
ConfigureCrystalReports();
}
private void ConfigureCrystalReports()
{
string reportPath = Server.MapPath("CrystalReport1.rpt");
rankingDSet = (DataSet) Cache["AppData"];
rankingDView = new DataView(rankingDSet.Tables[0]);
rptStockRankings = new ReportDocument();
rptStockRankings.Load(reportPath);
rptStockRankings.SetDataSource(rankingDSet);
ReportViewer_Rankings.ReportSource=rptStockRankings;
ReportViewer_Rankings.DataBind();
}