Designers

Snoops

   

 
Migrating to .NET: A Pragmatic Path to Visual Basic .NET, Visual C++ .NET, and ASP.NET
By Dhananjay  Katre, Prashant  Halari, Narayana  Rao  Surapaneni, Manu  Gupta, Meghana  Deshpande

Table of Contents
Chapter 4.   Post-migration Changes


In Visual Basic 6.0, application developers can use various designers such as the DHTML , WebClass , DataEnvironment , and the DataReport . None of these designers are supported in Visual Basic .NET.

DataEnvironment and DataReport are commonly used designers for generating the reports . When a Visual Basic 6.0 application is upgraded to Visual Basic .NET, the code compiles. However, there is a runtime warning for the DataReport designer, and the report cannot be shown in the upgraded application.

Crystal reports are part of Visual Studio .NET. The developer has to use crystal reports to generate the same reports in the upgraded application.

CODE EXAMPLES

Example 19

In the Visual Basic 6.0 application, the designers DataEnvironment and DataReport are added. In the DataEnvironment , a connection is established to the local SQL Server. The pubs database is selected on the local SQL Server. The project for this example is in the SampleDataReport-VB folder for this chapter. Figure 4-7 shows how to set the connection property for the DataEnvironment object.

Figure 4-7. Specifying the data link properties of the DataEnvironment object.

graphics/04fig07.gif

Right-click on the connection and select the Add command link. This will add a command object. Right-click on the command object and set the SQL command as shown in Figure 4-8. Now add a DataReport designer to the Visual Basic 6.0 application. Specify the Datasource property to the DataEnvironment added earlier. Set the DataMember property to the command added in the previous step. Now, when the application needs to display the report, it can invoke the show command on the DataReport , and the fields are shown on the screen.

Figure 4-8. Specifying the SQL command for the DataEnvironment .

graphics/04fig08.gif

When the application is upgraded to Visual Basic .NET, it compiles successfully. However, there is a runtime warning, and the code does not execute in Visual Basic .NET because the designer DataReport is not supported in Visual Basic .NET.

In Visual Basic .NET, the same functionality is achieved with the help of crystal reports. The project for this example is in the SampleDataReport-VB.NET folder for this chapter. In the preceding example, select the upgraded Visual Basic .NET project. Right-click on the project and add a crystal report file to the project. Right-click on the crystal report file and select the Database Add/Remove Database option. Select the OLE DB (ADO) option. Select Microsoft OLE DB Provider for SQL Server. Select the appropriate server name and the database name. Figure 4-9 shows the screen for specifying the server name and the database name . Now select Add Command and type in the SQL for data retrieval as shown in Figure 4-10.

Figure 4-9. Specifying the SQL Server and database name on a crystal report.

graphics/04fig09.gif

Figure 4-10. Add Command to specify SQL for the crystal report.

graphics/04fig10.gif

Now from the field explorer window select the fields of the database table and drag them onto the crystal report. First add a new form to the project. Then add a crystal report viewer object to the newly added form. Whenever the application needs to display the report, the above-added form needs to be activated and shown.

Thus, crystal reports can be used in Visual Basic .NET to get the same functionality as the provided by the designers in Visual Basic 6.0.


Snoops

   
Top


Migrating to. NET. A Pragmatic Path to Visual Basic. NET, Visual C++. NET, and ASP. NET
Migrating to. NET. A Pragmatic Path to Visual Basic. NET, Visual C++. NET, and ASP. NET
ISBN: 131009621
EAN: N/A
Year: 2001
Pages: 149

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net