Online Book Reader

Home Category

Access Cookbook - Ken Getz [325]

By Root 2127 0

Figure 17-9. .NET web services supply a basic set of documentation when you navigate to them

You may find it helpful to take a look at the web services' Web Services Description Language (WSDL) document, which you can get to by clicking on the Service Description link (see Figure 17-9). You can think of the WSDL as the equivalent of a type library for a web service.

If the web service was created with Microsoft .NET 1.0 you can also use a special automatically-generated test form to call a web service method interactively from Internet Explorer. This test form is available by clicking on the name of a method you wish to test (see Figure 17-9). In Microsoft .NET 1.1 (Visual Studio .NET 2003), by default, you no longer get the test form when calling the web service remotely. If you're using a .NET 1.1 web service, the test form is disabled when used from a remote client (anything other than localhost), so you can't depend on the test form for help.

Of course, neither the .NET 1.0 test form nor the WSDL for a web service takes the place of good documentation. If you are using a web service in a production environment, you're going to need for the web service's creator to supply you with documentation that should include a thorough discussion of the web services input parameters and return value.

See Also


Working with ADO.NET Datasets in Microsoft Office (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnofftalk/html/office08012002.asp).

MSXML documentation (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/xml_obj_ixmldomnodelist_4kvo.asp).

17.6. Print an Access Report from .NET Windows Form Application


Problem


The Solution in Recipe 12.2 illustrates how to print an Access report from Excel. Is it also possible to print an Access report from a .NET Windows Form application?

Solution


Printing an Access report from another application requires you to automate the Access application. The Solution in Recipe 12.2 shows how to do this from Excel, which like Access is a COM-based program. The process for automating Access from a .NET application is very similar. The only difference is that a .NET application cannot directly call a COM program (or component). To call a COM-based program from .NET, you must obtain a runtime callable wrapper that calls the COM-based program on your behalf. (This process is the reverse of calling a .NET component from a COM-based program as discussed in the Solution in Recipe 17.1.) Runtime callable wrappers are also known as interop assemblies.

Using the Office 2003 setup program, you can install the interop assemblies for various Office applications, including Access. Depending on the path you take through the Office 2003 setup program, you may or may not have installed the interop assemblies. Fortunately, you can modify an existing Office 2003 installation to add one or more interop assemblies. The interop assemblies are listed under each product in the Office 2003 setup program under the heading ". NET Programmability Support."

If you have installed the interop assemblies, when you set a reference to Access 2003 or another Office application from Visual Studio .NET, your code will automatically use the installed interop assembly.

Follow these steps to create a Windows Form application named AccessReporter that automates Access 2003, opens the 17-06.MDB database, and runs the rptArtistAlbum report:

Start Visual Studio .NET.

Create a new VB .NET Windows Application project named AccessReporter.

Delete the initial Form1.vb file from the project.

Select Project → Add Windows Form... to add a Windows Form file to the project named PrintArtistReport.vb.

Add the controls listed in Table 17-3 to the form. Size the controls to your liking.

Table 17-3. Controls for the Windows Form file for the project PrintArtistReport.vb

Control

Name

Text

Label

lblArtist

Artist:

ComboBox

cboArtist

n/a

Button

cmdRunReport

Run Report

Checkbox

chkPreview

Preview report before printing

Double-click the cmdRunReport

Return Main Page Previous Page Next Page

®Online Book Reader