You are on page 1of 36

RBDMS Report Creation

in Visual Studio 2010


Lido Beach 2011 Training Session
This guide discusses the procedures for developing RDLC
reports in Visual Studio 2010 SP 1. It provides new users with
some getting-started advice and outlines the conventions the
developers have adopted for integrating reports into
RBDMS.NET applications.
Ground Water Protection Council
Virtual Engineering Solutions, Inc. Coordinate Solutions, Inc.
April 9, 2011

III

Contents
RBDMS Report Creation Process in Visual Studio 2010 Projects .................................................1
Major Changes in Microsoft Reports ..........................................................................................1
1. The work area: Report Designer controls ................................................................... 2
2. Converting RDLC 2005 files to RDLC 2008 ................................................................... 5
3. Handling underlying queries ...................................................................................... 9
4. Adding a tablix with the Report Wizard .................................................................... 10
5. Adding other output options .................................................................................... 13
Creating a New Project ............................................................................................................. 13
An Abridged and Generic Process for Creating RBDMS Reports in Visual Studio 2010 ............. 16
1. Adding a report to the project .................................................................................. 17
2. Specifying the dataset you will use to bind the report .............................................. 17
3. Adding header and footer information ..................................................................... 17
4. Developing the report body ..................................................................................... 18
5. Creating report parameters for filtering returned datasets and linking subreports ... 20
6. Saving your work ..................................................................................................... 21
Creating and Associating Filters ................................................................................................ 21
Adding Reports to the Application Menu ................................................................................. 23
Testing and Debugging Reports, Filters, and Menus ................................................................. 24
About Subreports ..................................................................................................................... 24
Appendix. Report Designer Updates for Entity Framework Projects ........................................ 25

LIDO BEACH 2011 TRAINING SESSION

RBDMS Report Creation in Visual Studio 2010


Reports are usually defined through several components:

A data source, usually defined by a query (SELECT, WHERE, ORDER BY) run against a SQL Server
database or a data view within SQL Server. Multiple table adapters that describe a set of these
queries or views can be defined as a dataset within a Reports project in VisualStudio.NET 2008
and 2010. This dataset specifies the data source for purposes of report data binding. Visual
Studio 2010 also gives developers the option of using an ADO.NET Entity Data Model (.edmx) as
a binding source (see the Appendix).

A template with data fields bound to the fields exposed in the table adapter or view.

A filter that contains elements compatible with the query or view and that is associated with the
report parameters, the values of which may be defined programmatically by the host
application or passed from one report to another.

Whats the difference between RDL and RDLC files? Report language definition (.rdl) files are
created with the SQL Server 2008 version of the Report Designer and are meant to be run from the Report
Server. Report language definition client (.rdlc) files are created with VS2008 and higher and are client side.
RDL and RDLC formats have the same xml schema. However, in RDLC files, some values (such as query text) are
allowed to be empty, which means that they are not immediately ready to be published to a Report Server. The
missing values can be entered by opening the RDLC file using the SQL Server 2008 version of Report Designer.
(You have to rename .rdlc to .rdl first.)
RDL files are fully compatible with the ReportViewer control runtime. However, RDL files do not contain some
information that the design-time of the ReportViewer control depends on for automatically generating databinding code. By manually binding data, RDL files can be used in the ReportViewer control.
RDLC files require the ReportViewer control, and no preview is available without running the project. However,
RDL and RDLC formats may be converted back and forth, and the RBDMS Reports module can accommodate
either format. Projects must be WinForm to use the VS2008 ReportViewer. WPF can use the ReportViewer
control, but only in Windows compatibility mode. Silverlight supports use of the ASP.NET ReportViewer.
Version 10 of ReportViewer is being used in PA RBDMS, OH RBDMSW and is proposed for use in CO RBDMSW.
This document covers only the client-side processing of reports, since the .rdlc format has proven to be easier
to use with RBDMS applications. This document does not include the steps to run or preview RDLC reports
from within Visual Studio, which requires a separate window with a ReportViewer control to host the RDLC
report.
Reference and further reading: http://www.gotreportviewer.com/.

Major Changes in Microsoft Reports


Visual Studio itself is jam-packed with a plethora of updates that will be of interest to developers. Those
that appeared immediately of interest to the RBDMS Reports module are as follows.
1. The ReportView controls have been upgraded to support the SQL Server 2008 or later version of
Reporting Services and provide .NET Framework multi-targeting.

2. The report designer supports the RDL 2008 schema, and support for the RDL 2005 schema has
been dropped other than in local processing mode. Therefore, when you open your existing RDL
2005 reports in the Report Designer, you will need to upgrade them. Additionally, the
conversion of RDLC files from the 2005 schema to the 2008 was found to work well.
3. The Report Wizard has been very nicely updated to guide you through the required tasks to
create a finished report and new Chart and Gauge wizards have been included for presentation
options.
4. Report export to Microsoft Word, Excel, and comma-separated value lists has been enhanced.
Word export is compatible with version 2000 and higher, and the Excel rendering extension now
supports rendering of subreports and nested data regions.

1. The work area: Report Designer controls


Within Visual Studio 2008, the following components of the workspace are of importance:
1. The toolbox of standard report controls.
2. The work space, which allows drag-and-drop, page layout, and spreadsheet-like action for tables,
charts, and letter reports.
3. The Solution Explorer, which is used to manage project content.
4. The Data Sources pane, which is used to manage the database objects referenced in the report
project.
5. The Properties pane, which is used to manage formatting requirements at both the page and the
individual control level.

The work space has undergone a significant facelift in Visual Studio 2010, essentially allowing designers
to work in more of a print-preview mode. The following additional areas, which were previously
somewhat arcane, have been exposed in the report designer work area:
6. The Report Data pane, which is used to add and to define report-specific items such as images and
parameters with right-click functionality.
7. The Row and Column Grouping area, which allows the designer to specify how the displayed
information is grouped for totals and other manipulations.
Another immediately apparent change in Visual Studio 2010 is the ability to drag and drop data fields
from the Report Data pane directly into the report body or to use a field picker from a right click in the
cell. This vast improvement speeds layout development by eliminating endless scrolling in an
inconveniently placed Properties control or typing =Fields!Blah.Value in every cell to effect data binding
to the source.

Note about the samples and processes discussed herein: The following samples and processes discussed
trace the creation of two report projects in Visual Studio 2010 against SQL Server 2008 databases. The
projects and the discussion of how these report processes have been updated in were created for
illustrative (classroom) purposes only.
The process of adding the report to an RBDMS front-end application and building the necessary filter
sets and menu objects within the RBDMS Admin application(s) remains essentially the same across both
the WinForm and Silverlight versions. The Silverlight version of RBDMS Admin offers the added ability to
specify filtering wizards.

2. Converting RDLC 2005 files to RDLC 2008


The following steps illustrate the conversion wizard action to update the Lido2009ReportTraining
project in Visual Studio 2010.
1. Open the project in Visual Studio 2010. The Visual Studio Conversion Wizard will open.

2. Choose whether to create a backup (Yes) and specify the location:

3. Click Next and read through the summary information:

4. Click Finish to load the solution.

5. Opt whether to view the conversion log:

6. Choose to convert to the RDLC 2008 format so that you can get all of the nice editing features:

7. The report will open in the report designer:

Should you convert to RDLC 2008? Is converting to ReportViewer version 10 a good idea for
your installation?
Existing code base for RBDMS.NET installations in MS, OK, and possibly others uses ReportViewer version 9
(.RDLC 2005). PA RBDMS.NET, OH RBDMSW, and (soon) CO RBDMSW use ReportViewer version 10. Unless you
(or your developer) are prepared to recompile the application with updated references to ReportViewer
version 10 in RbdmsWpfControlsBase, do not even consider converting your existing reports to RDLC 2008.
They will no longer work!
Updating an application to version 10 of the ReportViewer requires removing the references to version 9,
adding the version 10 references, compiling the Visual Studio solution and re-deploying. Current version 9
users should consider combining this with the next version upgrade of their application.

3. Handling underlying queries


As mentioned on page 1, .rdlcs include a SELECT statement for the report. In Visual Studio 2008, this
query was included in the .xml underlying the .rdlc. You can access the query by right-clicking the report
in the Solution Explorer and selecting Open with | XML (Text) Editor. Here is an example of the query
underlying a Visual Studio 2008 report from the OH RBDMSW project:
<Query>
<DataSourceName>RBDMSConnectionString</DataSourceName>
<CommandText>SELECT
Loc.LocStation, Obs.ObsDate, Obs.Matrix,
Parameter.ParamDescription, Result.Units, Result.Qualifier, Result.ResultValue,
Result.Dilution, Result.DetectionLimit,
CollParameter.ListSeq, CollParameter.UpperCritLimit,
CollParameter.LowerCritLimit, dbo.CriteriaExceedance(Result.Qualifier,
Result.ResultValue,
CollParameter.LowerCritLimit,
CollParameter.UpperCritLimit) AS Exceedance
FROM
CollObs INNER JOIN
Result INNER JOIN
Obs ON Result.ObsID = Obs.ObsID INNER JOIN
Parameter ON Result.ParamID = Parameter.ParamID INNER
JOIN
Loc ON Obs.LocID = Loc.LocID ON CollObs.ObsID = Obs.ObsID
INNER JOIN
Coll AS CollO ON CollObs.CollID = CollO.CollID INNER JOIN
Coll INNER JOIN
CollParameter ON Coll.CollID = CollParameter.CollID ON
Result.ParamID = CollParameter.ParamID
WHERE
(Coll.CollName = @AnalysisSet) AND (CollO.CollName =
@ObservationSet)</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
<rd:DataSetInfo>
<rd:DataSetName>AnalyticalResults</rd:DataSetName>
<rd:TableName>AnalyticalResults</rd:TableName>
<rd:TableAdapterFillMethod>Fill</rd:TableAdapterFillMethod>
<rd:TableAdapterGetDataMethod>GetData</rd:TableAdapterGetDataMethod>
<rd:TableAdapterName>AnalyticalResultsTableAdapter</rd:TableAdapterName>
</rd:DataSetInfo>
</DataSet>

To safeguard against .sql injection attacks, RBDMS developers then parse out the WHERE clause
programmatically.
The Visual Studio 2010 report designer does not include any .sql in .rdlc files. This is an example of the
<Query> tag in Visual Studio 2010 for a dataset specification:
<Query>
<DataSourceName>PARBDMSDataSet</DataSourceName>
<CommandText>/* Local Query */</CommandText>
</Query>
<rd:DataSetInfo>
<rd:DataSetName>rptHFProduct</rd:DataSetName>
<rd:SchemaPath>C:\Projects\PA\ReportsPA\ReportsPA\rptHFProduct.xsd</rd:Sche
maPath>

<rd:TableName>rptHFProduct</rd:TableName>
<rd:TableAdapterFillMethod>Fill</rd:TableAdapterFillMethod>
<rd:TableAdapterGetDataMethod>GetData</rd:TableAdapterGetDataMethod>
<rd:TableAdapterName>rptHFProductTableAdapter</rd:TableAdapterName>
</rd:DataSetInfo>

Therefore, depending on the circumstances of the specific report, the programmer must either insert
the SELECT statement with a paste operation regardless of the data source (see Appendix) or execute
logic similar to that being used in the PARBDMS project. If the local query message is in the command
text, then we can use SELECT * From " whatever is inside <rd:tablename>. For example, the following
code snippet was added in a ProcessReport and getSubQueryParams:
ndCmdText = elm2.GetElementsByTagName("CommandText").Item(0)
If ndCmdText.InnerText = "/* Local Query */" Then
m_sql = "select * from " & tblName
Else
m_sql = ndCmdText.InnerText
End If

4. Adding a tablix with the Report Wizard


The output of the Report Wizard is called a tablix (Table + Matrix) and it is a new object within the
designer. The tablix allows the display of both dynamic and static data, with category and subcategory
labels stacked for display in the same columns. Tablixes also give the developer a great deal of control
over subtotals (Sum, Count, Avg) in the body and in the subtotals.
Because a tablix results from the output of the Report Wizard, the usefulness of the wizard for basic
reports breaks down in step 4 below because the Values pane of the Arrange Fields dialog box must
have at least one value and such a display option may not be required. However, for reports that include
dynamic groupings of row and column information, continuing with the wizard does a very nice job of
helping to visualize the final layout. Therefore, for basic reports, add the .rdlc to the project manually
and edit it.
1. In the Solution Explorer, right click the project, select Add | New Item.
2. In the Add New Item dialog, choose Report Wizard and name the new .rdlc. Click Add.

10

3. Choose the dataset you will use for binding and click Next.

4. Drag and drop the fields for the table into the layout through the Arrange fields dialog.

11

5. Choose a layout from the options offered:

6. Apply a style:

12

7. Click Finish to open your new tablix report and edit it as needed.

5. Adding other output options


Other presentation output options are now included in Visual Studio 2010, among them charting and
gauge display of data:

Creating a New Project


Both versions of Visual Studio include an option to create a report project with a MainForm (2008) or a
Form1 (2010) and Report1.rdlc items created for you. When you create a report project, many of the
steps to start a report template are accomplished via a wizard. Although some people find the wizard
easier to use, some options you may otherwise exercise are taken away and others are forced on you.

13

Therefore, the following example will track the wizard action only through project setup and data source
configuration. We will consider ways to add reports to the project separately. For purposes of this
example, we will create a new report project to hold sample reports from PARBDMS.
1. Open Visual Studio and click File | New Project. The New Project dialog box will open and allow
you to target .NET Framework versions, choose templates, and name the project. Click OK.

2. The Report Wizard and the Data Source Configuration Wizard will both launch. In the Choose a
Data Source Type dialog, choose Database:

14

3. For the database model, choose Dataset and click Next:

4. Choose the data connection or click New Connection to configure and test the connection:

15

5. Save the connection and choose your database object:

6. At this point, cancel the Report wizard. We will proceed manually.


Note: You must specify a data source for a report project because this wizard will launch
automatically if the project does not contain any server connections or defined datasets. Other data
sources besides SQL Server are available, but only SQL Server connections should be used in RBDMS.

An Abridged and Generic Process for Creating


RBDMS Reports in Visual Studio 2010
Once the project is established, the process of creating a report can be accomplished in six (compound)
steps:
1.
2.
3.
4.
5.
6.

Add the report to the project.


Specify the dataset you will use to bind the report.
Add header and footer information
Develop the report body.
Create report parameters for filtering returned datasets and linking subreports.
Save your work.

These steps are described in further detail below.

16

1. Adding a report to the project


a. In the Solution Explorer, right click the project, select Add | New Item.
b. In the Add New Item dialog, choose Report and name the new .rdlc file.

2. Specifying the dataset you will use to bind the report


a. In the Report Data pane, select New|Dataset.
b. In the Dataset Properties dialog, name the dataset, select the data source you will use to
bind the report, and choose from the available datasets in the source. Click OK.

Hint: Forget to include a field? Need to revise the query?


Sometimes while working with report projects, you will find that you need to edit
the dataset or view underlying a particular report to add fields or to streamline a
query. Follow these steps:
1.

If your change is a minor one of adding or deleting a field from the dataset,
open the [datasetname].xsd file by double-clicking it in the Solution
Explorer, making your change in the table adapter, and saving the file. If
your change is one of altering a view to add a table or significantly change
the returned results, edit the view in SQL Server Management Studio and
save your changes.

2.

In Visual Studio, open the report you want to update with the new data
source.

3.

Refresh the data source for the report within Visual Studio:
a.

In the Report Data pane, right-click the data source and choose
Refresh.
OR

b.

In the Data Sources pane, click the Refresh

icon.

3. Adding header and footer information


a. From the Report menu, select Page Header to view the page header space.
b. Drag textboxes from the Toolbox into the header space and develop your report header
information, such as a title and other layout embellishments. Set any formatting desired in
the Properties pane. Include placeholders for any report parameters you will be adding,
such as To: and From: dates to filter the data to a specified range (see step 5).
c. From the Report menu, select Page Footer to view the page footer space.
d. Drag textboxes from the Toolbox into the footer space. To enter a run date or page
numbers, right-click the empty textbox and click Expression. The Expression dialog will
open and you can choose from and edit a number of useful expressions for building report
information. Expressions are correct when the red squiggle underscores in the expression
are completely cleared. Useful expressions for report footers include the run date [=Now()]

17

and page numbers for printing [="Page " & Globals.PageNumber & " of " &
Globals.TotalPages].

Hint: Headers and footers may be set to display on every page of the report, or be
excluded from the first and/or last page. This option is a property of the
Header/Footer which can be set in the Header [Footer] Properties dialog. Right-click
in the header or the footer and choose Header [Footer] Properties. Footers should be
used only when the report is long enough to span multiple pages.

4. Developing the report body


a. Depending on your layout requirements, start by dragging a List box, a Table, or a Matrix
control into the work area. Build the body of the report inside the list box or within the table
or matrix control.

Hint: List boxes and tables allow the report to grow, so if you fail build the report
with one of these container controls, the report will stop printing after the first record.
While it is not impossible to add a list box after the template is in a state of advanced
development, it is awkward and not fun.

b. Drag and drop the desired fields from the list in Report Data pane into the table, matrix, or
list control OR click in each cell to select the desired field for binding from the shortcut
menu accessed by the table icon.

c. To change the configuration of the tablix or add an expression, right click in the container
control.
d. Add desired formatting to selected fields through the Properties pane. Use the multi-select
keys (Shift+Click and Ctrl+click) to select groups of fields to receive similar formatting.
e. Right-click on the tablix row header where you would like to add a group for sorting, if your
report will include tabular totals that require specifying a grouping and sort order. The
shortcut menu allows a number of options for revising the tablix organization.

18

The Add Group selection will allow you to specify whether the group you are adding will be
a parent group or a child group. To view the properties of an existing group, select Row
Group from this shortcut menu. Be sure to specify the Group on: option in the Group
Properties dialog.

Hint: If you know that your report will have multiple groups and dynamic content, you
might consider using the Report Wizard to specify the initial layout of the tablix.

f.

To add a total to a grouped column, right click the tablix cell where you want the total to
display and choose Add Total | Column or Row.

19

g. Add graphical design elements.


i. For long grid reports, you may wish to introduce some eye-relief. To alternate
background color on the report grid, use an iif expression for the BackgroundColor
property for the row where you want the alternating color to begin, like so:
=iif(RowNumber(Nothing) Mod 2, "AliceBlue", "White")

ii. To add an image to an .rdlc,


1. In the Report Data pane, right click the Images folder icon. Then click Add
Image and navigate to the location of the image file.
2. Click Open to add the image to the project Image folder.
3. Drag the image to the desired position on the work area. The Images
Properties dialog will open.
4. Specify the name of the image, the wording for a tooltip, if desired, and
other properties associated with sizing, visibility, hyperlink action, and
borders. Click OK.

Hint: Although it is also possible to create a link to an external image to be used


by the report or to store the image in the database, additional programming is
required and the EnableExternalImages property must be set to True in
ReportViewer. Therefore, using the Embedded option for the image source is
recommended.

Other hints for controlling the layout: If you find that you are having
problems with the layout stretching horizontally off your targeted paper size for
printing, be aware of two factors in your debugging:
1.

Make sure you set the CanGrow option on the individual control
properties on your report to False (unless that is desirable behavior).

2.

The reality is that an .rdlc template is basically a text file. Controlling the
placement of elements is often a matter of squish, jiggle, check, re-squish,
jiggle again, recheck, and cuss.

5. Creating report parameters for filtering returned


datasets and linking subreports
a.

In the Report Data pane menu, right click the Parameters folder and select Add
Parameter. The Report Parameters Properties dialog box will open.

b.

Define the parameter.


i.

If the parameter will be used to filter the returned data to a specified range (To/From
date range, Operator, Well Type, etc.) in the report, the name should be meaningful

20

enough to link the parameter name to the desired filtering function. You will need to
build a filter control with the same name in RBDMS Admin. Click OK.
ii.

If you are creating the report parameter for linking a subreport, the name should be the
same as the field that will link the subreport to the main report. Be sure to select the
correct data type and indicate whether a blank value is allowed (True). Click OK.

iii.

If the parameter will be used to call a filter set, name the parameter CollName of data
type Text, and enter a default value that will match the name of the filter set you will
build in RBDMS Admin. Click OK.
An RBDMS Convention: The RBDMS.NET developers use the report parameter
CollName to specify the name of the filter set created on the Edit Filters page in
WinAdmin.NET. A report parameter CollName should therefore be added to each
.rdlc file you plan to add to an RBDMS application menu. The Default Value you
specify for the CollName parameter in each report should match the name of the
filter set you define in RBDMS Admin for use with the report. The CollName
parameter therefore serves to associate the report with the desired filter control
collection.
Any other report parameter that you define to be passed to the .rdlc (e.g., start
and end dates, etc.) also must be defined as a filter control in RBDMS Admin and
assigned to the CollName (NameYouChose) filter set on the Edit Filters page of
RBDMS Admin.
You do not have to define a parameter for the filterable columns because those
are appended to the WHERE clause of the sql unless the ParameterOnly option in
the filter control defined in RBDMS Admin is set to True. In this case, the column
does not get added to the WHERE clause and is passed as a report parameter.

c.

Drag the report parameter from the Report Data pane into a textbox control in the correct
position in the report. For example, in the case of a parameter that will be used to filter
data return to a specified StartDate, the correct position probably will be in the report
header. For a parameter that will be used to link a subreport, the correct position will be
some discrete location in the body of the subreport, and the visibility of the textbox control
containing it should be set to Hide.

6. Saving your work


The program will prompt you, but dont forget.

Creating and Associating Filters


The dynamic filtering parameters associated with each report are defined in RBDMS Admin on the Edit
Filters form. These filter controls give you the ability to limit the results returned by the query
underlying the report to the dataset of interest. The WinForm version of the application can be
downloaded from http://RbdmsOnline.org/downloads/MS/RbdmsWinSetup.zip.
1. From the Start menu, select All Programs | GWPC | RBDMS WinAdmin.

21

2. In RBDMS Admin, make sure that your database connection is pointed to your correct instance
of the database on the Forms | Configuration Options page, Database Connection tab. If it is
not already pointing to the correct installation, reset the connections
3. With Windows Explorer, copy the .rdlc file you created into the folder shown for the appropriate
report path, as shown in Configuration | Settings page.
4. In RBDMS Admin, select Forms | Edit Filters to open the two-paned page that is used to manage
report filter controls.
5. In the left pane on the New Record row, enter the CollName you specified as a report
parameter in Visual Studio. Enter a description for the filter collection in the Description column.
6. Build the filter collection to include those needed to handle any report parameters that your
users will need to retrieve information. To do this, select the desired filter controls on the right
and then drag and drop them on the Set Name record you created. You may need to build the
necessary individual filter controls in the right pane first by completing the form grid. Be sure to
test any .sql statements included in individual filter controls in SQL Server Management Studio
before using them.
7. Right click the Set Name record to preview the filter.

Hint: You may delete items from your set on the left pane without deleting the control
from the database. However, deleting filter controls from the right pane is a permanent
action.

If you must create a new filter control on the right pane of the Edit Filters page in RBDMS Admin, the
following data dictionary snippet may provide useful hints in how to complete each new control record.
The snippet shows the columns in the DevControls table, which governs the filtering in RBDMS.NET:
Column Name

Data
Type

Length

ControlName

varchar 50

xml

text

Nulls Default

NO

21474836
YES
47

Description

Unique name for the control (i.e., "Operator")


Contains the XML serialization of extra information for
the control object

ColumnName varchar 50

YES

Column name for this control. Can include table name


if needed.

Prompt

varchar 50

YES

The label to create next to the left of the comparison


and criteria controls.

DataType

varchar 255

YES

The data type for the criteria


("String","Integer","DateTime","Single","Double")

ControlType

varchar 255

YES

The control type to use


("TextBox","ComboBox","CheckBox","DateCombo","Lis
tBox")

DefaultValue

varchar 255

YES

A default value to use for the criteria.

22

Column Name

Data
Type

Length

Nulls Default

Description

varchar 255

YES

A tooltip to show when the cursor is over the control.


Useful when you need a longer description than will fit
in the label area.

CompareItems varchar 255

YES

A semicolon delimited list of SQL comparison operators


to make available (<; <=;=;>=;>;<>;Like)

DefaultCompar
varchar 10
e

YES

The default comparison criteria (i.e., "=").

YES ((0))

If true then the comparison control will be hidden. This


is helpful if you are using the default value for the
comparison control and you don't want the user to
change it.

Tooltip

HideCompare bit

InputMask

varchar 50

YES

A data input mask to use for a textbox control.

MinValue

varchar 50

YES

The minimum allowable value.

MaxValue

varchar 50

YES

The maximum allowable value.

SQL

varchar 1024

YES

A SQL statement to retrieve data to display in a combo


or listbox.

DisplayField

smallint 2

YES

The integer position of the description field in the SQL


query result (0 based).

ValueField

smallint 2

YES

The integer position of the value field in the SQL query


result (0 based).

ListItems

text

21474836
YES
47

A semicolon delimited list of items to use in a combo or


listbox. This is an alternative to populating using a SQL
query.

Hidden

bit

YES

True if the control is hidden and always used with a


defaultValue and DefaultCompare

Format

varchar 50

YES

Format specification

Sort

bit

YES ((0))

If true then this field will be available for sorting.

Required

bit

YES ((0))

If true this filter criteria must include non-null


comparison criteria and comparison value.

ParameterOnly bit

YES ((0))

If true this criteria will be passed as a parameter only


and not part of the WHERE clause.

Adding Reports to the Application Menu


Once the report is built, you can add the report to the application through RBDMS Admin for the smoke
test. Menu management is done in RBDMS Admin.

23

1. Open RBDMS Admin, switch to the Security tab of the Menus and Security page.
2. In the Rights pane, scroll to the New Record row and specify the right for the report you wish to
add.
3. Expand the Rights record and assign the EveryOne role to the right. Be sure to click off the new
record to commit the write action.
4. Switch to the Menus tab of the Menus and Security page.
5. In the Select Menu dropdown, select Reports. This menu is the live menu for the RBDMS.NET
WPF Reports menu.
6. Add the report .rdlc to the menu by selecting the record in the right pane and dragging it to the
Well Data node in the left pane.
7. Click Save Updates.

Testing and Debugging Reports, Filters, and Menus


Reports are best tested and previewed within the target application in a test/development
environment.
1. Open the target RBDMS application and select the Reports explorer.
2. Expand the Reports menu to confirm that your new menu item is visible and that, when
invoked, each control in your defined filter set works as planned.
3. Check the report at runtime to determine any necessary formatting revisions or debugging.

About Subreports
Subreports must be developed as separate .rdlcs from the main report and should not have a header or
footer. A main report can contain many subreports. Subreports also may contain their own subreports if
desired, but these must be defined within those subreports (not the main report). As a convention of
the RBDMS developers, subreports are always named with the prefix zz.
You can embed a sub-report into the main report body by selecting the Subreport control from the
Toolbox pane in Visual Studio. When you insert a subreport control on the main report body, you must
specify the data link to the subreport as a named parameter. For example, in MSRBDMS.NET, the
subreport zzConstructCasing is linked to the Well Completions report by the ConstructKey which is
specified as the parameter value ConstructKey in the Subreport Properties dialog. Also in the Subreport
Properties dialog, your entry in the Parameters| Name field of the linked subreport definition must
match the parameter value name (in this example, ConstructKey must be added in the Parameters |
Name field). If you forget to link the subreport properly to the main report, the subreport will not work.

24

Appendix. Report Designer Updates for Entity


Framework Projects
One of the new updates in the Visual Studio 2010 report designer is support for Entity Framework
projects.
The Entity Data model for reports has not been used against the existing RBDMS.NET application
codebase in MS, OK, and PA. The programming for these applications uses SqlDataAdapters, commands,
and DataSets. New development in Silverlight (CO RBDMSW) is proposed to be based on Entity
Framework, and further guidance in this matter will evolve.
As stated previously, the Visual Studio 2010 report designer does not include any SQL in .rdlc files and
the programmer must insert the SELECT statement somehow regardless of the data source (see pages 910 for two possibilities). To safeguard against .sql injection attacks, RBDMS developers then parse out
the WHERE clause programmatically. In Entity Framework projects, the data entity model is referenced
as the ObjectDataSourceType in the <rd:DataSetInfo> tag.
<Query>
<DataSourceName>ReportsPAEntity</DataSourceName>
<CommandText>/* Local Query */</CommandText>
</Query>
<rd:DataSetInfo>
<rd:DataSetName>ReportsPAEntity</rd:DataSetName>
<rd:TableName>PARBDMSEntities2</rd:TableName>
<rd:ObjectDataSourceSelectMethod>ProductChemicals</rd:ObjectDataSourceSelec
tMethod>
<rd:ObjectDataSourceType>ReportsPAEntity.PARBDMSEntities2, Model1.Designer.vb,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
</rd:DataSetInfo>

The Entity Data model offers the means to flatten portions of highly relational data structures in much
the same way database views can be used. The result is that multiple tables can be queried as a single
logical entity.
The process of vertically splitting one entity across two tables in the Entity Data Model is shown in detail
below. For the example, we will work with the following tables from the RBDMS HF module:

25

Within a Visual Studio 2010 Report project, we can create a model with a single entity representing the
ProductChemical and Chemical tables in the following steps:
1. Add a new model to your project: select Add | New Item.

2.

Choose ADO.NET Entity Data Model.

26

3. Select Generate from database. Click Next.

27

4. Use the wizard to select an existing connection to the database or create a new connection.
5. From the Choose Your Database Objects dialog box, select the tables you want to work with.
Leave the Pluralize and Foreign key options checked. Click Finish.

6. The resulting model is shown below.

7. Next, merge the ProductChemical and Chemical tables into a single entity:

28

a. Copy the scalar properties for the items of interest from the Chemical entity to the
ProductChemical entity. You can use the multi-select keys to do this copy-and-paste
step:

b. Right-click the Chemical entity and select Delete.

29

c. A dialog box will ask you if you want to delete the Chemical table. Click No to preserve
the Chemical definition in the store model layer.

d. Click the ProductChemical entity to view the Mapping Details window. (To show the
Mapping Details window, click View | Other Windows | Entity Data Model Mapping
Details.

e. In the Mapping Details window for the ProductChemical entity, click Add a Table or
View and select the Chemical table. This adds the Chemical information to the mappings
for the ProductChemical entity.
f.

Under the Chemical table in the Mapping Details window, map the ChemicalName
column to the ChemicalName property. Also, make sure that the PKey property is
mapped to the PKey column of the Chemical table, like so:

30

g. Save your model.


8. When creating a report against the model, in the Choose a Database Model for your new
report, select Entity Data Model and then proceed normally to choose the dataset.

31

9. The resulting selection allows report creation from a flattened data object in the same way a
database view now accomplishes the task.

32

You might also like