﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » Updates and Information » StrataFrame Users Contributed Samples  » Reporting: Create a typed dataset from Business Objects that can be bound at design time to reports, etc</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 10:40:46 GMT</lastBuildDate><ttl>20</ttl><item><title>Reporting: Create a typed dataset from Business Objects that can be bound at design time to reports, etc</title><link>http://forum.strataframe.net/FindPost8417.aspx</link><description>I needed to create some reports which need data from multiple tables.  Originally I was creating Business Objects based off of views..but that's just ugly to me so.....&lt;br&gt;
&lt;br&gt;
I created a dataset that I could bind Crystal Reports to at design time.&lt;br&gt;
&lt;br&gt;
First I created a class that would output an .xsd file with the dataset schema.&lt;br&gt;
&lt;br&gt;
[quote][codesnippet]Imports System.Data&lt;br&gt;
Imports MicroFour.StrataFrame.Business&lt;br&gt;
&lt;br&gt;
Public Class CreatePICDataset&lt;br&gt;
&lt;br&gt;
    Private Shared GenderBO As New PICData.Gender&lt;br&gt;
    Private Shared InsuranceCardBO As New PICData.InsuranceCard&lt;br&gt;
    Private Shared InsuranceTypeBO As New PICData.InsuranceType&lt;br&gt;
    Private Shared LanguageBO As New PICData.Language&lt;br&gt;
    Private Shared PatientBO As New PICData.Patient&lt;br&gt;
    Private Shared PatientHistoryBO As New PICData.PatientHistory&lt;br&gt;
    Private Shared RaceBO As New PICData.Race&lt;br&gt;
    Private Shared VoterRegBO As New PICData.VoterReg&lt;br&gt;
    Private Shared PICDS As New DataSet&lt;br&gt;
&lt;br&gt;
    Public Shared Sub CreateDataset()&lt;br&gt;
        PICDS.DataSetName = "PICDataSet"&lt;br&gt;
        AddBOTableToDataset(GenderBO)&lt;br&gt;
        AddBOTableToDataset(InsuranceCardBO)&lt;br&gt;
        AddBOTableToDataset(InsuranceTypeBO)&lt;br&gt;
        AddBOTableToDataset(LanguageBO)&lt;br&gt;
        AddBOTableToDataset(PatientBO)&lt;br&gt;
        AddBOTableToDataset(PatientHistoryBO)&lt;br&gt;
        AddBOTableToDataset(RaceBO)&lt;br&gt;
        AddBOTableToDataset(VoterRegBO)&lt;br&gt;
        PICDS.WriteXmlSchema("C:\PICDataSet.xsd")&lt;br&gt;
    End Sub&lt;br&gt;
&lt;br&gt;
    Private Shared Sub AddBOTableToDataset(ByVal myBO As BusinessLayer)&lt;br&gt;
        myBO.FillDataTable("Select * from " &amp; myBO.TableName &amp; " where 1 = 0")&lt;br&gt;
        PICDS.Tables.Add(myBO.CurrentDataTable)&lt;br&gt;
    End Sub&lt;br&gt;
&lt;br&gt;
End Class&lt;br&gt;
[/codesnippet][/quote]&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
I call the CreateDataSet method of this class anytime I change my BO's /DB structure.  I then copy the output file to my project and set it as an embedded resource.&lt;br&gt;
&lt;br&gt;
I then created a class which inherits from dataset and reads it's schema from the embedded .xsd file in the project&lt;br&gt;
&lt;br&gt;
[quote][codesnippet]Imports System.Data&lt;br&gt;
&lt;br&gt;
Public Class PICDataset&lt;br&gt;
    Inherits DataSet&lt;br&gt;
&lt;br&gt;
    Private AppAssembly As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()&lt;br&gt;
    Private AppAssemblyPath As String = Me.AppAssembly.GetName().Name().Replace(" ", "_")&lt;br&gt;
&lt;br&gt;
    Public Sub New()&lt;br&gt;
        Try&lt;br&gt;
            Me.ReadXmlSchema(GetResource("PICDataSet.xsd"))&lt;br&gt;
        Catch ex As Exception&lt;br&gt;
            MsgBox(ex.Message)&lt;br&gt;
        End Try&lt;br&gt;
    End Sub&lt;br&gt;
&lt;br&gt;
    Private Function GetResource(ByVal FileName As String) As System.IO.Stream&lt;br&gt;
        Try&lt;br&gt;
            Return Me.AppAssembly.GetManifestResourceStream(Me.AppAssemblyPath &amp; "." &amp; FileName)&lt;br&gt;
        Catch ex As Exception&lt;br&gt;
            MessageBox.Show("Error returning resource: " &amp; ex.ToString(), "GetResource!", MessageBoxButtons.OK, MessageBoxIcon.Error)&lt;br&gt;
            Return Nothing&lt;br&gt;
        End Try&lt;br&gt;
    End Function&lt;br&gt;
&lt;br&gt;
End Class[/codesnippet][/quote]&lt;br&gt;
&lt;br&gt;
At design time I can now bind a report to a Typed Dataset (you could go a step further and add the relationships in code, but I do this in Crystal)&lt;br&gt;
&lt;br&gt;
At runtime to populate my dataset for a report, I create an instance of the dataset class and add tables using the currentdatatable from my business objects&lt;br&gt;
&lt;br&gt;
[codesnippet][quote]            Dim ds As New PICDataset&lt;br&gt;
            ds.Tables(PatientBO.TableName).Load(PatientBO.CurrentView.ToTable.CreateDataReader)&lt;br&gt;
            ds.Tables(GenderBO.TableName).Load(GenderBO.CurrentDataTable.CreateDataReader)&lt;br&gt;
            ds.Tables(LanguageBO.TableName).Load(LanguageBO.CurrentDataTable.CreateDataReader)&lt;br&gt;
            ds.Tables(RaceBO.TableName).Load(RaceBO.CurrentDataTable.CreateDataReader)&lt;br&gt;
            ds.Tables(InsuranceCardBO.TableName).Load(InsuranceCardBO.CurrentDataTable.CreateDataReader)&lt;br&gt;
            rptPIF_English.SetDataSource(ds)[/quote][/codesnippet]&lt;br&gt;
&lt;br&gt;
Hopefully this helps someone.&lt;br&gt;
&lt;br&gt;
Jerome</description><pubDate>Mon, 26 Nov 2007 09:45:32 GMT</pubDate><dc:creator>Jerome Barnett</dc:creator></item><item><title>RE: Reporting: Create a typed dataset from Business Objects that can be bound at design time to reports, etc</title><link>http://forum.strataframe.net/FindPost12826.aspx</link><description>Hi Jerome:&lt;br&gt;
&lt;br&gt;
You wouldn't mind if I added this to my examples project would you?&lt;br&gt;
&lt;br&gt;
I believe I'll put this in the Chapter 10 slot.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
C. T. Blankenship</description><pubDate>Mon, 26 Nov 2007 09:45:32 GMT</pubDate><dc:creator>Charles Thomas Blankenship</dc:creator></item><item><title>RE: Reporting: Create a typed dataset from Business Objects that can be bound at design time to reports, etc</title><link>http://forum.strataframe.net/FindPost11607.aspx</link><description>Ben,&lt;br&gt;
&lt;br&gt;
You should probably delete my link to it then.  No need to have it here twice.  &lt;br&gt;
&lt;br&gt;
(I didn't know you could move stuff...that's cool  :w00t: )</description><pubDate>Wed, 19 Sep 2007 16:30:05 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Reporting: Create a typed dataset from Business Objects that can be bound at design time to reports, etc</title><link>http://forum.strataframe.net/FindPost11591.aspx</link><description>There, it's now in the samples :)</description><pubDate>Wed, 19 Sep 2007 12:51:51 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Reporting: Create a typed dataset from Business Objects that can be bound at design time to reports, etc</title><link>http://forum.strataframe.net/FindPost11590.aspx</link><description>Yeah, I might need to move this post... just have to remember how to do it.</description><pubDate>Wed, 19 Sep 2007 12:50:51 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Reporting: Create a typed dataset from Business Objects that can be bound at design time to reports, etc</title><link>http://forum.strataframe.net/FindPost11584.aspx</link><description>Jerome, &lt;br&gt;
&lt;br&gt;
Thanks for this very nice sample.  There is a forum for just this sort of thing, the [b]StrataFrame Users Contributed Samples[/b] ([url]http://forum.strataframe.net/Forum26-1.aspx[/url]) forum, and I posted there, linking back to this post.  It could get lost here :D&lt;br&gt;
&lt;br&gt;
Thanks!</description><pubDate>Wed, 19 Sep 2007 11:06:32 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Reporting: Create a typed dataset from Business Objects that can be bound at design time to reports, etc</title><link>http://forum.strataframe.net/FindPost11566.aspx</link><description>Thank you very much, Jerome! :-)&lt;br&gt;
&lt;br&gt;
I don't know if it helped someone other so far, but it helped me a lot!&lt;br&gt;
&lt;br&gt;
Thanks again and friendly greetings,&lt;br&gt;
&lt;br&gt;
Ralph</description><pubDate>Wed, 19 Sep 2007 06:59:51 GMT</pubDate><dc:creator>Ralph Rutschmann</dc:creator></item></channel></rss>