locked
How to make business objects available to rdlc? RRS feed

  • Question

  • User-651208615 posted

    Hi Community

        Using ASP.NET,  Vs2008 and c# I built an ASP.NET web project application that will
    use Microsoft Reportviewer to produce reports from a business object.

        first I created the business object and press F5 and it compiled (I don't want to
    use the App_Code folder but the option didn't even popup) so the business object.cs is
    off of the root.

        Next I created the rdlc but when I chose Data ->  show datasources the only thing
    that showed in the data sources were the test datasets that I created for testing other reports
    that use App_Code folder.  No business ojbects but they don't show when  I
    select Data -> show datasources.  I never see Add Datasource from the Data menu.

        So I created the aspx page and put the Microsoft Reportviewer control on it to see
    if I could see the business object there.  When I selected the report I saw the rdlc but
    underneath when I select chose datasource I did not see the business object (I didnt even see the
    test datasets anymore even though I am not going  to use those). I still never see Add Datasource
    from the Data menu

        I can't seem to find a way to run the Datasource configuration wizard because that
    would give me the option to access the business object. So I figured maybe something happened
    to my environment I ran the command  to reset the VS2008 ide devenv /setup and the
    other devenv options but I still never see Add Datasource from the Data menu.

         I am using controls from the Ajax Control Toolkit in my web page.

         I am using layers.

         In a nutshell I am trying to create a business object that has a SqlDataReader that
    reads a record and that record while be displayed using Reportviewer (the business object
    contains other methods).

        Below is a mock up of the business object so the questions is how do I get this business
    object to show in datasoures pane/ be read by the Reportviewer? 

        fyi, this method "public void reportRowData(DateTime iDate )" is where the business object
    provides the data to the report from.

     

    using System;
    using System.Data;
    using System.Configuration;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Collections;
    using System.Drawing;
    using System.IO;
    using System.Xml;
    using System.Collections.Generic;<o:p></o:p>

    <o:p> </o:p>

    ********* BELOW STARTS THE DAL ************************** <o:p></o:p>


    using ProjMain;
    namespace ProjMain

    {
    public class projClass
    {
    //
        public
    projClass ()<o:p></o:p>

    {<o:p></o:p>

    }

    public class MainClass
    {
    private DateTime InDate;
    private int inQty;
    private int inCost;

    <o:p> </o:p>

    private MainData AmtData = new MainData ();


    public DateTime Date
    {
    get { return InDate; }
    set { InDate = value; }
    }

    public int Qty
    {
    get { return inQty; }
    set { inQty = value; }
    }

    public int Cost
    {
    get { return inCost; }
    set { inCost = value; }
    }


    public MainClass ()
    {
    }
    //
    public MainClass (DateTime Date, int Qty, int Cost)
    {
    InDate = Date;
    inQty = Qty;
    inCost = Cost;

    //*****************************************************************************
    }
    }
    public class MainData
    {
    private List<dataRpt> dRpt;

    public MainData (DateTime dDate)
    {

    SqlConnection SqlConn = AmtData.GetConnection();
    string strSelect = @"select Date, Qty, Cost " +
    " from AmtTable " +
    " where Date = " + dDate +
    " order by Date";
    SqlCommand cmdSelect = new SqlCommand(strSelect, SqlConn);
    SqlDataReader reader;
    SqlConn.Open();
    reader = cmdSelect.ExecuteReader(
    CommandBehavior.SingleRow);
    while (reader.Read())
    {
    InDate = Date;
    inQty = Qty;
    inCost = Cost;
    }
    dRpt =
    new List<dataRpt> ();
    dRpt.Add(
    new objRpt(vDate, inQty, inCost,));
    }
    public List< dataRpt > rptRecord()
    {<o:p></o:p>

    return dRpt;
    }
    }
    }
     <o:p></o:p>

    **************  END OF ABOVE DAL **********************<o:p></o:p>

    **********   BELOW STARTS THE BAL *************************
    using System;
    using System.Data;
    using System.Configuration;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Data.SqlClient;

    namespace AccessClass
    {
    public class ReadBusinessObject
    {

    private projClass.MainClass getReport = new projClass.MainClass ();
    {

    }
    public List<lReport> getOjbReport(DateTime dDate)
    {<o:p></o:p>

    getReport.MainData (dDate);

    }

    }
    }<o:p></o:p>

    **************  END OF ABOVE BAL **********************<o:p></o:p>

    <o:p> </o:p>

    <o:p> </o:p>

    **** THE PRESENTATION LAYER BELOW PASSES THE DATE TO THE BAL ******<o:p></o:p>

    getObjReport(CurrentDate);<o:p></o:p>

    <o:p> </o:p>

    <o:p> </o:p>

     

    Thursday, February 24, 2011 8:24 PM

All replies

  • User-381965707 posted

    Did you ever find an answer/solution to this problem? I'm trying to figure out the same thing!

    Tuesday, April 12, 2011 9:36 AM