Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Object Collection as Subreport DataSource Post Reply Post New Topic
Author Message
MasudulIslam
Newbie
Newbie


Joined: 18 Apr 2010
Online Status: Offline
Posts: 1
Quote MasudulIslam Replybullet Topic: Object Collection as Subreport DataSource
    Posted: 19 Apr 2010 at 4:27am
I'm using Object Collection as data source of main report as well as subreport. I can generate report of single Distributor with a collection of sales information using OBJECT COLLECTION Technology but facing problem when i want to create report with a number of Distributors with subreport containing sales info using object collection. i.e i need to setDataSource of the subreport, which shows sales info, for each Distributor in loop. pls take a look in the following code depicting where i need help : I don't want to use any ODBC connection for subreport DataSource.

Private Sub cmdDWSH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDWSH.Click
       
Dim DWSHs As New ArrayList
Dim dwsh As clsDWSH
Dim RptDwsh As New DWSH (This is Crystal Report File)
Dim colDistrib As List(Of clsDistributor)
Dim DistribDA As New DistributorDataAccess

colDistrib = DistribDA.GetDistributors()

If Not colDistrib Is Nothing Then
            
For i = 0 To colDistrib.Count - 1

    dwsh = New clsDWSH

     dwsh.AreaCode = colDistrib(i).AreaCod
     dwsh.AreaName = colDistrib(i).Ara
     dwsh.AreaManager = ObjArea.GetObjArea(dwsh.AreaCode).ManagerNam
     dwsh.DistribName = colDistrib(i).DistributorNam
     dwsh.DistribAddress = colDistrib(i).Addres
     dwsh.DistribMobile = colDistrib(i).Phon
     dwsh.ForMonth = cboMonth.Text
     dwsh.ForYear = cboYear.Text
     dwsh.ProdGroup = cboProdGrp.Text

     DWSHs.Add(dwsh)
     
     --(NOTE : I NEED TO SET THE SUBREPORT DATABASE IN THIS LOOP. I DON’T KNOW WHETHER IT IS POSSIBLE)--
     
Next i

RptDwsh.SetDataSource(DWSHs)

--(I WANTED TO PUT THE LINE OF CODE BELOW HERE BUT IT EXECUTES WITHOUT ANY OUTPUT)--

RptDwsh.Subreports(0).SetDataSource(Sales)

--(ABOVE LINE OF CODE WORKS FINE FOR SINGLE DISTRIBUTOR AND ALL SALES INFO OF THE DISTRIBUTOR BUT I NEED A NUMBER OF DISTRIBUTORS AND SALS INFO FOR EACH DISTRIBUTOR TO BE PRINTED)--

frmRptViewer.CrystalReportViewer.ReportSource = RptDwsh
frmRptViewer.ShowDialog()

End If

Exit Sub
errHandler:
        MessageBox.Show(Err.Description)
End Sub

---------------------------------------------

Private Function Sales () As ArrayList
On Error GoTo errHandler

        Dim SaleList As New ArrayList
        Dim ObjSale As clsSale
        Dim ColSale As List(Of clsSale)
        Dim SaleDA As New SaleDataAccess

        Dim i As Integer

        ColSale = SaleDA.GetSales(txtDistribID.Text)

        If Not ColSale Is Nothing Then
            For i = 0 To ColSale.Count - 1
               ObjSale = New clsSale

               ObjSale.SaleDate = ColSale (i).SaleDate
               ObjSale.ItemName = ColSale (i).ItemName
               ObjSale.QTY = ColSale (i).QTY
              ObjSale.UnitPrice = ColSale (i). UnitPrice

               SaleList.Add(ObjSale)
            Next i
        End If

        Return SaleList

        Exit Function
errHandler:
        MessageBox.Show(Err.Description)
    End Function


Edited by MasudulIslam - 19 Apr 2010 at 10:54pm
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 21 Apr 2010 at 7:52am
Perhaps I am missing something, why not have the  DADistributor load a dataset as opposed to a list and then use the dataset as your datasource?  They (datasets) are something that CR is designed to handle.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.027 seconds.