Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Create an instance of the strongly-typed DataSet Dim ds As New LiveDateLetter '----------------Live Date Letter Coordinator info----------------- 'create table adapter Dim taCoordinator As New LiveDateLetterTableAdapters.lookup_liveDateLetterCoordinatorTableAdapter() 'create data table Dim dtCoordinator As New LiveDateLetter.lookup_liveDateLetterCoordinatorDataTable() 'fill data table taCoordinator.Fill(dtCoordinator) 'For Each Row As LiveDateLetter.lookup_liveDateLetterCoordinatorRow In dtCoordinator ' Response.Write("Test data: " & Row.cLastName) 'Next 'create instance of CR and load the report Dim crLiveDateLetterPreview As New CrystalDecisions.CrystalReports.Engine.ReportDocument crLiveDateLetterPreview = New CrystalDecisions.CrystalReports.Engine.ReportDocument crLiveDateLetterPreview.Load(Server.MapPath("~\Reports\crLiveDateLetter.rpt")) 'Routine for pushing datasets into a report object PushReportData(ds, crLiveDateLetterPreview) 'set CR data source 'crLiveDateLetterPreview.SetDataSource(ds) crLiveDateLetterPreview.SummaryInfo.ReportTitle = "LiveDateLetterPreview" crLiveDateLetterPreview.SummaryInfo.ReportAuthor = User.Identity.Name.ToString 'bind CR to the CRViewer CrystalReportViewer1.ReportSource = crLiveDateLetterPreview CrystalReportViewer1.DataBind() End Sub Public Sub PushReportData(ByVal DsReportData As DataSet, ByVal oReport As ReportDocument) ' Calls SetData for the main report object ' Also calls SetData for any subreport objects Me.SetData(DsReportData, oReport) Dim oSubReport As ReportDocument For Each oSubReport In oReport.Subreports Me.SetData(DsReportData, oSubReport) Next End Sub Private Sub SetData(ByVal DsReportData As DataSet, ByVal oReport As ReportDocument) ' receives a DataSet and a report object (could be the ' main object, could be a subreport object) ' loops through the report object's tables collection, ' matches up the table name with the corresponding table ' name in the dataset, and sets the datasource accordingly ' This function eliminates the need for a developer to ' know the specific table order in the report Dim oTable As Table For Each oTable In oReport.Database.Tables oTable.SetDataSource(DsReportData.Tables(oTable.Name.ToString())) Next End Sub