Creating a report using an MSXML schema file
MSXML data sources can replace database connections when creating and running a report
Note:
MSXML schema files are currently used in reports created with C#.
To create a report using an MSXML schema file:
- Create a new BAM C# project.
-
Click Database > Import MS XML Schema ... and select the MSXML schema file.
The database file (.4db) file is created.
- Save the database file (.4db) file.
- Click File > New > C# > Report Data from Database (.4rdj).
-
Select the desired fields and click Finish.
The data model diagram (.4rdj) file is created.
- Save the data model diagram (.4rdj) file.
- Click Build > Compile File to compile the data model diagram and generate an .xsd file.
- Click File > New > Reports and select a report type.
- Open the Data View and browse for the .xsd generated from the .4rdj file.
- Add fields to your report.
- Open AppData.cs file within the ReportLauncher library.
-
Remove code applying to database connection, insert code using MSXML as a data source. For
example:
Open the AppData.cs file and remove the following lines of code:
// Get Data Provider and connection string from environment variable String provider = Environment.GetEnvironmentVariable("ADO_PROVIDER"); String connectionString = Environment.GetEnvironmentVariable("ADO_CONNECTION_STRING"); DbProviderFactory dataFactory = DbProviderFactories.GetFactory(provider); // Create the database connection using (DbConnection connection = dataFactory.CreateConnection()) { // Create the data model instance connection.ConnectionString = connectionString;
connection.Open();
Then add the following lines of code and save the file:using FourJs.Report.BAM.SQLReports.MsXmlDataSource;
String xmlFilePath = Environment.GetEnvironmentVariable("MSXML_FILE_PATH"); String converterPath = Environment.GetEnvironmentVariable("MSXML_CONVERTER_PATH"); using (DbConnection connection = MsXmlDataSource.CreateInstanceFromMsXml(xmlFilePath, converterPath)) {
- Open the Genero Configuration Management window and click the plus icons to add the two environment sets for the input file path and converter path.
-
For the input file path, add the following environment variables and click
OK:
- Type -
File
- Name -
MSXML_FILE_PATH
- Value -
$(ProjectDir)/msxml/'msxml database file'
- Type -
-
For the converter path, add the following environment variables and click
OK:
- Type -
File
- Name -
MSXML_CONVERTER_PATH
- Value -
$(GSTDIR)/lib/msxmlconvert.jar
- Type -
-
Execute the application.
The Report Launcher window opens.
- For the Select data model class to run section, click Add and navigate to the DataSourceLib.dll file in your project.
- For the Select report design section, click Add and navigate to the report design document .4rp file in your project.
-
Click Run.
The report is run using the MSXML database schema file.