Using URL Access in a Windows Application
Collapse the table of content
Expand the table of content

Using URL Access in a Windows Application

 

Applies To: SQL Server 2016 Preview

Although URL access to a report server is optimized for a Web environment, you can also use URL access to embed Reporting Services reports into a Microsoft Windows application. However, URL access that involves Windows Forms still requires that you use Web browser technology. You can use the following integration scenarios with URL access and Windows Forms:

  • Display a report from a Windows Form application by starting a Web browser programmatically.

  • Use the WebBrowser control on a Windows Form to display a report.

You can use the Process class to access a process that is running on a computer. The Process class is a useful Microsoft .NET Framework construct for starting, stopping, controlling, and monitoring applications. To view a specific report in your report server database, you can start the IExplore process, passing in the URL to the report. The following code example can be used to start Microsoft Internet Explorer and pass a specific report URL when the user clicks a button on a Windows Form.

// Sample click event for a Button control on a Windows Form  
private void viewReportButton_Click(object sender, System.EventArgs e)  
{  
   // Build the URL access string based on values supplied by a user  
   string url = serverUrlTextBox.Text + "?" + reportPathTextBox.Text +  
      "&rs:Command=Render" + "&rs:Format=HTML4.0";  
  
   // If the user does not check the toolbar check box,  
   // turn the toolbar off in the HTML Viewer  
   if (toolbarCheckBox.Checked == false)  
      url += "&rc:Toolbar=False";  
  
   // load report in the Web browser  
   try  
   {  
      System.Diagnostics.Process.Start("IExplore", url);  
   }  
  
   catch (Exception)  
   {  
      MessageBox.Show(  
         "The system could not open the specified report using Internet Explorer.",   
         "An error has occurred", MessageBoxButtons.OK, MessageBoxIcon.Error);  
   }  
}  

If you do not want to view your report in an external Web browser, you can embed a Web browser seamlessly as part of your Windows Form using the WebBrowser control.

To add the WebBrowser control to your Windows Form
  1. Create a new Windows application in either Microsoft Visual C# or Microsoft Visual Basic.

  2. Locate the WebBrowser control in the Toolbox Dialog Box.

    If the Toolbox is not visible you can access it by clicking the View menu item and selecting Toolbox.

  3. Drag the WebBrowsercontrol onto the design surface of your Windows Form.

    The WebBrowsercontrol named webBrowser1 is added to the Form

You direct the WebBrowser control to a URL by calling its Navigate method. You can assign a specific URL access string to your WebBrowser control at run time as shown in the following example.

string url = "http://localhost/reportserver?/" +  
             "AdventureWorks2012 Sample Reports/" +  
             "Company Sales&rs:Command=Render";  
webBrowser1.Navigate(url);  

Integrating Reporting Services into Applications
Integrating Reporting Services Using URL Access
Integrating Reporting Services Using SOAP
Integrating Reporting Services Using the ReportViewer Controls
URL Access (SSRS)

Community Additions

ADD
Show:
© 2016 Microsoft