Home All Groups Group Topic Archive Search About

asp.net 2 report problem with 3-tier design

Author
25 Sep 2006 8:51 AM
Bernie Beattie
How do you create a report when you have a 3-tier web application?  I have a
class that does all the data accessing for me, so I don't have direct access
to datasets in the user interface tier.  I was hoping I could just cheat the
report with a dummy dataset structure nut I'm not sure how to go about
creating the dummy dataset.

The alternative would be to create the report in code at runtime but I'm not
sure if that's possible either. I can't find any examples of this.

Can anyone help?

Thanks,

Bernie Beattie

Author
25 Sep 2006 2:13 PM
David R. Longnecker
You can reference your business (or directly to your data) layer in your
reporting layer.

So, for example, on your reporting project, reference the business layer
project in your solution (add reference > projects > business layer project,
in this case, called myBizLayer).  Now, you have access to the datagrids
and functions of that project.

From here, if you have a call to get information based off a user input number,
say a part lookup.  Your business layer contains a select for this that outputs
a DataRow.

--
int partNumber = Convert.ToInt32(lblPartNumber.Text);
DataRow partInfo = myBizLayer.getPartInfo(partNumber);
--

From here, you can use that DataRow (or DataSet, DataTable, etc) however
you please in your reporting project. Most of my projects are separated by
business, data, presentation (web, usually), and reporting. I use DataDynamics
ActiveReports and have found this to work like a champ and still keep the
layers of logic separated. 

If this isn't what you're meaning, reply back with an example or pseudocode
of how you're calling the data in your presentation tier and we can go from
there. :)

-dl

--
David Longnecker
Web Developer
Wichita Public Schools, USD 259

Show quoteHide quote
> How do you create a report when you have a 3-tier web application?  I
> have a class that does all the data accessing for me, so I don't have
> direct access to datasets in the user interface tier.  I was hoping I
> could just cheat the report with a dummy dataset structure nut I'm not
> sure how to go about creating the dummy dataset.
>
> The alternative would be to create the report in code at runtime but
> I'm not sure if that's possible either. I can't find any examples of
> this.
>
> Can anyone help?
>
> Thanks,
>
> Bernie Beattie
>
Author
27 Sep 2006 8:12 AM
Bernie Beattie
Thanks for your reply David.  First time anyone has replied to any of my posts!

I'm trying to use the asp.net 2.0 in-built reporting (rdlc) with a chart
control dropped on, but it requires to have a dataset/table bound immediately
when you create the report. This is the bit I'm finding tricky as the data is
accessed via a separate tier. I was hoping I could trick the report into
working by having a dummy business object with the fields that will be in my
dataset and somehow rebind the data at runtime. But it doesn't seem to work.

Maybe I need a different approach or use a different chart tool?

Thanks for your help,

Bernie Beattie

Show quoteHide quote
"David R. Longnecker" wrote:

> You can reference your business (or directly to your data) layer in your
> reporting layer.
>
> So, for example, on your reporting project, reference the business layer
> project in your solution (add reference > projects > business layer project,
> in this case, called myBizLayer).  Now, you have access to the datagrids
> and functions of that project.
>
> From here, if you have a call to get information based off a user input number,
> say a part lookup.  Your business layer contains a select for this that outputs
> a DataRow.
>
> --
> int partNumber = Convert.ToInt32(lblPartNumber.Text);
> DataRow partInfo = myBizLayer.getPartInfo(partNumber);
> --
>
> From here, you can use that DataRow (or DataSet, DataTable, etc) however
> you please in your reporting project. Most of my projects are separated by
> business, data, presentation (web, usually), and reporting. I use DataDynamics
> ActiveReports and have found this to work like a champ and still keep the
> layers of logic separated. 
>
> If this isn't what you're meaning, reply back with an example or pseudocode
> of how you're calling the data in your presentation tier and we can go from
> there. :)
>
> -dl
>
> --
> David Longnecker
> Web Developer
> Wichita Public Schools, USD 259
>
> > How do you create a report when you have a 3-tier web application?  I
> > have a class that does all the data accessing for me, so I don't have
> > direct access to datasets in the user interface tier.  I was hoping I
> > could just cheat the report with a dummy dataset structure nut I'm not
> > sure how to go about creating the dummy dataset.
> >
> > The alternative would be to create the report in code at runtime but
> > I'm not sure if that's possible either. I can't find any examples of
> > this.
> >
> > Can anyone help?
> >
> > Thanks,
> >
> > Bernie Beattie
> >
>
>
>
Author
27 Sep 2006 1:32 PM
David R. Longnecker
http://msdn2.microsoft.com/en-us/library/ms251784.aspx

Now, I'll be the first to admit that I left the RDLC reporting behind because
it... frankly, didn't make sense to me. ;)  I'm sure it's very powerful and
that it's just a learning curve for me, but none-the-less.  I didn't like
some of the complexities that it appeared to add and currently use ActiveReports.


The article above describes how to expose your business objects and then
adding an Object data source and referencing your class from there.  One
thing it doesn't point out in bold is what to do if your business objects
are in another project.  If that's the case, be sure to add a Reference (under
adding an Object data source, click Add Reference > Projects and select your
project, or browse if it's not a member of yoru current solution.).

From the example, you should be able to then drag/drop and/or associate your
data sets and values to charts, tables, matrices, etc.

-dl

--
David Longnecker
Web Developer
http://blog.tiredstudent.com

Show quoteHide quote
> Thanks for your reply David.  First time anyone has replied to any of
> my posts!
>
> I'm trying to use the asp.net 2.0 in-built reporting (rdlc) with a
> chart control dropped on, but it requires to have a dataset/table
> bound immediately when you create the report. This is the bit I'm
> finding tricky as the data is accessed via a separate tier. I was
> hoping I could trick the report into working by having a dummy
> business object with the fields that will be in my dataset and somehow
> rebind the data at runtime. But it doesn't seem to work.
>
> Maybe I need a different approach or use a different chart tool?
>
> Thanks for your help,
>
> Bernie Beattie
>
> "David R. Longnecker" wrote:
>
>> You can reference your business (or directly to your data) layer in
>> your reporting layer.
>>
>> So, for example, on your reporting project, reference the business
>> layer project in your solution (add reference > projects > business
>> layer project, in this case, called myBizLayer).  Now, you have
>> access to the datagrids and functions of that project.
>>
>> From here, if you have a call to get information based off a user
>> input number, say a part lookup.  Your business layer contains a
>> select for this that outputs a DataRow.
>>
>> --
>> int partNumber = Convert.ToInt32(lblPartNumber.Text);
>> DataRow partInfo = myBizLayer.getPartInfo(partNumber);
>> --
>> From here, you can use that DataRow (or DataSet, DataTable, etc)
>> however you please in your reporting project. Most of my projects are
>> separated by business, data, presentation (web, usually), and
>> reporting. I use DataDynamics ActiveReports and have found this to
>> work like a champ and still keep the layers of logic separated.
>>
>> If this isn't what you're meaning, reply back with an example or
>> pseudocode of how you're calling the data in your presentation tier
>> and we can go from there. :)
>>
>> -dl
>>
>> --
>> David Longnecker
>> Web Developer
>> Wichita Public Schools, USD 259
>>> How do you create a report when you have a 3-tier web application?
>>> I have a class that does all the data accessing for me, so I don't
>>> have direct access to datasets in the user interface tier.  I was
>>> hoping I could just cheat the report with a dummy dataset structure
>>> nut I'm not sure how to go about creating the dummy dataset.
>>>
>>> The alternative would be to create the report in code at runtime but
>>> I'm not sure if that's possible either. I can't find any examples of
>>> this.
>>>
>>> Can anyone help?
>>>
>>> Thanks,
>>>
>>> Bernie Beattie
>>>