<html> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Report Integration</title> <link rel="stylesheet" type="text/css" href="../../../../style.css"> </head> <body> <div class="CommonContent"> <div class="CommonContentArea"> <h1>Report Integration</h1><script> //We attach this function to a browser object as a variable so that if multiple of these blocks are //present on the same page, then they will simply over-write eachother with the same function instead //of generating a naming collision. window.WikiCodeFormattingCopyToClipboard = function copyToClipboard(sID){ var sContent = document.getElementById(sID).innerText; if( window.clipboardData && clipboardData.setData ) { clipboardData.setData("Text", sContent); } else { alert("You must enable javascript access to your clipboard for this feature to work. Please referr to your browser documentation or Google search for instructions."); } } </script><p><font color="#990000">This topic applies to .NET version only</font> </p><p>Now the existing report should be integrated into the application.</p> <p>Select the application form (Form1) in design view and drag ReportViewer icon from the toolbox onto the form.</p> <p>Select the ReportViewer control, and open the smart tags panel by clicking the triangle on the top right corner. Click the "Choose Report" drop-down list and select the PilotReport. A BindingSource (PilotBindingSource) is automatically created corresponding to the Pilot data source used in the report.</p> <p>Open the code view for the Form1. Find Form1_Load function and add the following code:</p> <span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">Form1.cs: <span class="fscMemberName">Form1_Load</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> Form1_Load(</span><span style="color: #0000FF;">object</span><span style="color: #000000;"> sender, EventArgs e) </span><span style="color: #008080;">2</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47_60_332_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47_60_332_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47_60_332_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47_60_332_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47_60_332_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47_60_332_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47_60_332_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47_60_332_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47_60_332_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_Load_744_47_60_332_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008000;">//</span><span style="color: #008000;"> Add data to the database</span><span style="color: #008000;"> </span><span style="color: #008080;">4</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> Db4oManager.FillUpDB(); </span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008000;">//</span><span style="color: #008000;"> Bind the Pilot list to the report DataSource</span><span style="color: #008000;"> </span><span style="color: #008080;">6</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #0000FF;">this</span><span style="color: #000000;">.PilotBindingSource.DataSource </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oManager.GetAllPilots(); </span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">this</span><span style="color: #000000;">.reportViewer1.RefreshReport(); </span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/> }</span></span></div></pre></div></div> </span> <span name="cs_wiki_filter" csw_filters="vb"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">Form1.vb: <span class="fscMemberName">Form1_Load</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47_8_387_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47_8_387_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47_8_387_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47_8_387_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47_8_387_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47_8_387_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47_8_387_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47_8_387_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47_8_387_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub Form1_Load()</span><span id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_Load_857_47_8_387_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> Form1_Load(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> sender </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> System.Object, </span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> e </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> System.EventArgs) </span><span style="color: #0000FF;">Handles</span><span style="color: #000000;"> </span><span style="color: #0000FF;">MyBase</span><span style="color: #000000;">.Load </span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008000;">'</span><span style="color: #008000;"> Add data to the database</span><span style="color: #008000;"> </span><span style="color: #008080;">3</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> Db4oManager.FillUpDB() </span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #008000;">'</span><span style="color: #008000;"> Bind the Pilot list to the report DataSource</span><span style="color: #008000;"> </span><span style="color: #008080;">5</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;"> </span><span style="color: #0000FF;">Me</span><span style="color: #000000;">.PilotBindingSource.DataSource </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oManager.GetAllPilots() </span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">Me</span><span style="color: #000000;">.ReportViewer1.RefreshReport() </span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">Me</span><span style="color: #000000;">.ReportViewer1.RefreshReport() </span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div> </span> <p>Db4oManager takes care of opening db4o connection on the first request. However the connection should be closed manually on the application termination:</p> <span name="cs_wiki_filter" csw_filters="cs"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">Form1.cs: <span class="fscMemberName">Form1_FormClosed</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> Form1_FormClosed(</span><span style="color: #0000FF;">object</span><span style="color: #000000;"> sender, FormClosedEventArgs e) </span><span style="color: #008080;">2</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53_76_122_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53_76_122_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53_76_122_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53_76_122_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53_76_122_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53_76_122_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53_76_122_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53_76_122_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53_76_122_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsCS.ZipsForm1.Cs_Form1.Cs_Form1_FormClosed_1137_53_76_122_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> Db4oManager.CloseDb(); </span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/> }</span></span></div></pre></div></div> </span><span name="cs_wiki_filter" csw_filters="vb"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">Form1.vb: <span class="fscMemberName">Form1_FormClosed</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">1</span><img id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53_8_169_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53_8_169_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53_8_169_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53_8_169_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53_8_169_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53_8_169_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53_8_169_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53_8_169_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53_8_169_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub Form1_FormClosed()</span><span id="ResourcesReferenceImplementation_StrategiesReporting.NET_ReportingReportsVB.ZipsForm1.Vb_Form1.Vb_Form1_FormClosed_1252_53_8_169_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> Form1_FormClosed(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> sender </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Object</span><span style="color: #000000;">, </span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> e </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> System.Windows.Forms.FormClosedEventArgs) </span><span style="color: #0000FF;">Handles</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Me</span><span style="color: #000000;">.FormClosed </span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> Db4oManager.CloseDb() </span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/> </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div> </span></div> </div> <div id="footer"> This revision (3) was last Modified 2007-05-23T18:14:12 by Tetyana. </div> </body> </html>