SpriteHand
Module Border
  Most recent blog entries
Module Border
Populating a Crystal Report from DataSets
Andy's Blog By Andy Beaulieu on 1/14/2004 9:00 AM

In an n-tier application using Crystal Reports, it is necessary to populate reports from offline DataSets instead of using a direct DB connection. This class allows feeding a Crystal Report with 1 or more DataSets (in the case of subreports, you can have the DataSets in the same order as they appear in the main Crystal Report).

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class CCrystalUtilities

    Public Shared Function GetReportDocument(ByRef oRpt As ReportDocument, ByRef dsDataSets() As DataSet) As ReportDocument

        ' this function accepts a Path to a report and an array of DataSets to use
        ' to fill the report (in the case of nested reports, we need to use multiple
        ' datasets per report)

        Dim iDataSetNum As Integer

        ' set the main report's DataSource
        oRpt.SetDataSource(dsDataSets(iDataSetNum))
        iDataSetNum += 1

        Dim mySection As Section
        Dim mySections As Sections
        Dim myReportObject As ReportObject
        Dim myReportObjects As ReportObjects
        Dim mySubReportObject As SubreportObject
        Dim mySubRepDoc As New ReportDocument()

        'Declare all of the sections of the main report
        mySections = oRpt.ReportDefinition.Sections

        'Loop through the sections in the main report to find the 
        'subreport(objects)
        'then open the subreport and set the datasource to the subreport()

        For Each mySection In mySections
            myReportObjects = mySection.ReportObjects

            For Each myReportObject In myReportObjects
                If myReportObject.Kind = ReportObjectKind.SubreportObject Then
                    'Subreport Found - convert the report to a sub report type
                    mySubReportObject = CType(myReportObject, SubreportObject)

                    'Set the specific instance of this subreport
                    mySubRepDoc = mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)

                    mySubRepDoc.SetDataSource(dsDataSets(iDataSetNum))
                    iDataSetNum += 1
                End If
            Next
        Next

        ' return the complete report
        Return oRpt

    End Function

End Class

Comments (2)

Module Border Module Border
Module Border
  Blog_List
Module Border
Module Border Module Border
Module Border
  Subscribe
Module Border

RSS

Module Border Module Border
Module Border
  Diversions
Module Border

DESTROY ALL INVADERS
A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. Created using Silverlight 2.
PLAY IT

INFO AND CODE



SORT THE FOOBARS
A game where you need to sort the good foobars from the bad ones. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



POLYGON PHYSICS DEMO
A demo showing polygon physics where the user draws physics objects with the mouse. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SILVERLIGHT ROCKS!
Destroy the asteroids before they destroy your ship! Created using Silverlight 2.
PLAY IT

INFO AND CODE



FISH GAME
A simple game of harpoon-the-fish. Written using the AJAX Sprite Toolkit.
PLAY IT

INFO AND CODE

Module Border Module Border
Module Border
  Search_Blog
Module Border
Module Border Module Border
Module Border
  Blog_Archive
Module Border
Module Border Module Border
Copyright (c) 2008 andy.beaulieu.com - Login