Visual FoxPro to Visual Basic® .NET

Book description

Starting with simple examples, you¿ll see how the multi-user, local area network applications that Visual FoxPro developers are used to building are constructed in Visual Basic .NET. You¿ll learn how to use Crystal Reports to build reports like the ones you build in FoxPro. You¿ll discover how to use DataAdapters and datasets instead of DBFs. You¿ll see examples of the paradigm shift that client-server programming imposes, and why .NET solves that problem (even when you wouldn¿t need to solve it in FoxPro.) And you¿ll learn how to give your FoxPro and Visual Basic applications smart client remote data access.

You¿ll understand how to begin the construction of a database project in Visual Basic with a container form and a MainMenu instead of using _Screen and MSYSMENU. You¿ll learn how variables are declared and used; how menus are controlled; how to use events, and why you have to use events in VB when they¿re unnecessary in FoxPro. You¿ll learn how to build inheritable forms, Visual Basic¿s answer to FoxPro¿s form class templates, to reduce programming to a minimum. You¿ll learn why properties are like variables in FoxPro, but more like functions in VB. And you¿ll learn where Visual Basic adds features that you didn¿t have in FoxPro and didn¿t know that you needed. You¿ll learn where to look for all of those FoxPro commands and functions that you need. And in case you haven¿t yet used SQL Server with FoxPro, the examples will demonstrate how it¿s done first in FoxPro, then in VB .NET.

  • Shows how to build a typical application in Visual FoxPro, including DBF, SQL Server and Internet access; then demonstrates how to build the same type of application in VB .NET

  • Highlights the main differences in specific issues, including printing, events, data access, creation and use of properties

  • Contains an appendix listing the principal FoxPro commands and functions and their Visual Basic equivalents

  • Includes a table showing where to find the settings in the FoxPro¿s Tools, Options menu pages in VB .NET

  • Shows how to access data remotely from your FoxPro and VB .NET applications

  • Explains how project DLLs are created and used in other projects within a solution

  • Shows how to use middle tier business objects to simplify ongoing development

  • Source code downloadable from www.samspublishing.com

Table of contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. Acknowledgments
  4. We Want to Hear from You!
  5. Introduction
    1. About This Book
    2. Who Should Read This Book
    3. How This Book Is Organized
    4. What's Not Included
    5. An Offer You Can't Refuse
  6. 1. Differences Between Visual FoxPro and Visual Basic .NET
    1. A Whole New World
    2. The Integrated Development Environment (IDE)
      1. Typing Commands in the Command Window
      2. The Toolbox
      3. Tab Ordering
      4. Projects and Solutions
      5. Compiler Output Formats
      6. The Code Window
      7. The Document View Window
      8. Bookmarks and Task Lists
      9. The Server Explorer
      10. What Can You DO in the IDE?
      11. The Class Browser and Visual Basic .NET's Class View
      12. The Object Browser
      13. The Properties Window
      14. Getters and Setters Versus ASSIGN and ACCESS Methods
      15. Shortcut Keys
      16. The Tools, Options Dialog
      17. The Task Pane Manager
      18. The Output Window and Your Application Menu
      19. Customizing the IDE
    3. The Visual Basic .NET Solution Explorer
      1. Intermediate Language
      2. DLLs
      3. Other Characteristics of a Visual FoxPro Project
      4. Using Tables to Store FoxPro Project Components
      5. File Types Used in Visual Basic Projects
      6. Project Information
    4. Command Syntax
    5. Flow of Control
      1. Calling a Function, Procedure, or Method
      2. String handling
      3. Ending Your Program
      4. Do...ENDDO and Other Loops in Visual FoxPro
      5. Loops in Visual Basic .NET
      6. Conditional Execution in Visual FoxPro
      7. Conditional Execution in Visual Basic .NET
        1. If Expr Then...Else...End If
        2. Select Case
        3. Switch(VisualBasic Namespace)
    6. Variables, Enums, Arrays, Collections, and Fields
      1. Data Types
      2. Variable Scope Declaration in Visual FoxPro
      3. Variable Declarations in Visual Basic .NET
      4. Enumerations, Arrays, and Collections
        1. Enumerations
        2. Arrays
      5. Fields
    7. Functions and Subroutines (Procedures)
      1. Function Declarations
        1. Functions and Procedures in FoxPro
        2. Functions and Subroutines in Visual Basic .NET
        3. Constructors: Init vs. New
        4. Implementing Interfaces
      2. Summary of Visual Basic Declarations
        1. So What Should I Use?
        2. A footnote on overloaded methods in .NET
    8. Classes, Namespaces, Properties, and Forms
      1. Instantiating objects in Visual Basic .NET
      2. Property Procedures in Visual Basic .NET
      3. Forms
    9. Events
      1. Events in Visual FoxPro
      2. Events in Visual Basic .NET
      3. RaiseEvent
      4. How to Declare an Event in a Class
        1. Using Events in a Data Access Class
      5. The Form
    10. Compiler Directives
    11. Data
    12. Data Binding
    13. Error Handling and Debugging
      1. TRY...CATCH
      2. Debugging
      3. FoxPro Debugging Aids
      4. Visual Basic .NET Debugging Aids
    14. Summary
  7. 2. Building Simple Applications in Visual FoxPro and Visual Basic .NET
    1. Building a Simple Application in Visual FoxPro
      1. Creating a Simple Form Controls Class Library
      2. Field Mapping
      3. Creating the Form Using Your Subclassed Controls
      4. Form Methods
      5. Adding the Command Buttons
        1. The Add Button Code
        2. The Edit Button Code
        3. The Save Button Code
        4. The Cancel Button Code
        5. The Delete Button Code
        6. The Previous and Next Buttons
        7. The Browse Button Code
      6. Creating a Form Template
        1. Changing Form Code into Class Code
        2. Cosmetics
      7. Running the Form
    2. Building a Simple Application in Visual Basic .NET
      1. Creating a Customers Table
      2. Designing the Form
      3. Creating a Dataset
      4. Building the Form
      5. Form Methods
      6. Adding the Command Buttons
        1. The Add Button Code
        2. The Edit Button Code
        3. The Save Button Code
        4. The Cancel Button Code
        5. The Delete Button Code
        6. The Previous and Next Buttons
        7. The Browse Button Code
    3. Summary
  8. 3. Building a Visual FoxPro Application for SQL Server
    1. Why Three-Tier?
      1. Getting Our Test Data Ready
    2. Creating the SQL Database and Loading Your Tables
    3. Writing the Sample Application
    4. The Form Template
      1. How to Use the FlatFileForm Template
    5. A Search Form Template
      1. How to Use the EasySearch Template
    6. The Data Tier
      1. Running the Application
    7. What's Next?
  9. 4. A Visual Basic .NET Framework
    1. Starting the New Windows Application Project
      1. The AppScreen Form Properties
    2. Adding a Windows Controls Library
    3. Building Your First Inheritable Form
      1. Coding the Form Class
    4. Programming with Class
      1. Automating Data Access
        1. How BaseForm Load Works
      2. Loading the List Box and Displaying a Record When Clicked
        1. How LoadList Click Works
      3. Utility Routines
        1. How the Inputs Subroutine Works
    5. Click Event Code for the Form's Buttons
      1. How the Button Code Works
        1. How btnDelete Click Works
        2. How btnSave Click Works
        3. How btnCancel Click Works
      2. How to Use This Template
    6. Summary
  10. 5. Adding Internet Access
    1. ASP and Database Development
    2. Internet Access in Visual FoxPro 7
      1. Installing Web Connection
      2. Building Your Application
      3. The Main Program
    3. The StandardForm Class Template
      1. The Internet Server
      2. How Web Connection works
    4. Writing Web Connection Functions
      1. Passing Parameters
        1. GET Parameters
        2. POST Variables
      2. An XML Primer
      3. The Customer Form
    5. Introducing the Server
      1. The SEND2DBF and SEND2SQL Functions
      2. Database Design Still Matters
    6. Modifying the Data Tier to Add Internet Data Access
    7. Building XML Web Services with Visual FoxPro 8
    8. XML Web Services in Visual Basic .NET
      1. A Main Form for the Sample Application
      2. Building a Web Service for the Sample Application
      3. Changes to the CONFIG.WEB File
      4. Web Service Functions
      5. How It Works
    9. Adding References to the Web Service to Your Client
      1. Code for the Windows Application to Use the Web Service
      2. How It Works
      3. The EditCustomer Form
      4. How It Works
      5. Using Remoting Instead of Web Services
    10. Summary
  11. 6. Data Access
    1. Data Access in Visual FoxPro Before Visual FoxPro 8
      1. The DBF Format
      2. Creating a Table
      3. Using Local Tables (DBFs)
      4. Aliases
      5. Cursors
      6. Supporting Cast
      7. Buffering
        1. TableUpdate() and TableRevert()
        2. The Phantom Record
      8. Indexes
    2. Database Containers
      1. Local Views
      2. Remote Views
      3. SQL Pass-Through
      4. Connections and Connection Strings
      5. SQLExec()
      6. Other SQL Commands
      7. The Upsizing Wizard
    3. New Features in Visual FoxPro 8
      1. The CursorAdapter Class
        1. Finding Your CursorAdapter
        2. Controlling the CursorAdapter's Actions in Code
        3. Final Thoughts on the CursorAdapter
      2. The XMLAdapter Class
        1. Reading an XDR
        2. Reading XML into a Cursor
        3. Building a Diffgram
        4. Building an XML String from a FoxPro Cursor
        5. Building a Web Service in FoxPro 8
      3. FoxPro Data Access Notes and Comments
    4. Data Access in Visual Basic .NET
      1. Disconnected Data Access
      2. Connections
      3. Data Adapters
        1. Using a DataAdapter with a FoxPro Table
        2. Generated Code for the DataAdapter and Dataset
      4. Datasets
        1. Using the DataAdapter to Build a Dataset
        2. Relationship Between XML, Datasets, and XML Schemas
      5. Typed Datasets
        1. Exploring the Typed Dataset
      6. The Data Form Wizard
      7. The Generated Code
        1. Loading the Dataset
      8. Data Binding
        1. What Else Can You Do with Typed Datasets?
        2. Tables
        3. Rows
        4. Columns
      9. XML Web Services
        1. Adding an Update Function
      10. How to Use the Web Service
    5. Summary
  12. 7. XML
    1. The Structure of XML
      1. Encoding
      2. Namespaces
      3. Data Models: XDR and XSD
      4. Examples of XML
    2. Representation of Complex Structures
    3. Hierarchical XML
    4. The Document Object Model
    5. Commands to Move Data Between a Table and XML
      1. CursorToXML()
      2. XMLToCursor()
    6. How FoxPro Implements XML
      1. Using XML to Read Other Types of Data
      2. Receiving XML Files Directly
    7. Importing XML into Visual Basic .NET
      1. Direct Access to SQL Server with XML
      2. Using the XML DOM to Call a Web Service
      3. Using the XML DOM to Validate Documents
      4. XMLUpdateGrams
      5. DiffGrams in Visual FoxPro 8
      6. The Visual FoxPro CursorAdapter
      7. Creating a CursorAdapter to Read XML
    8. Reading XML into a Visual Basic .NET Dataset
      1. The Visual FoxPro XMLAdapter
    9. Using XML and Data Islands to Reduce Server Load
      1. Data Islands
    10. Related Technologies: XPATH and XSLT
    11. Extensible Style Sheet Transformations (XSLT)
    12. Summary
  13. 8. Screen Design
    1. The Base Control Classes
    2. Creating the Startup Screen for Your Application
      1. The Startup Screen for Your Visual FoxPro Application
      2. The Startup Screen for Your Visual Basic .NET Application
    3. Creating Menus
      1. The FoxPro Menu
      2. The Visual Basic .NET MainMenu Control
      3. Traversing the Controls in a Form
    4. Subclassing Controls
      1. Subclassing the FoxPro Screen Controls
      2. Using Your Subclassed FoxPro Controls
      3. Subclassing the Screen Controls in Visual Basic .NET
        1. Using Your Subclassed .NET Controls
        2. Enabling/Disabling the Controls on a Form
    5. Data Binding
      1. Data Binding in FoxPro
      2. Data Binding in Visual Basic .NET
        1. Manually Binding Data
        2. Using Generic Code to Bind Controls to Data Columns
        3. Introducing the BindingContext
      3. A Simple FoxPro Screen to Demonstrate Binding and Navigation
      4. The Equivalent Form in Visual Basic .NET
        1. Coding the Form
      5. Updating the Data Source Tables
        1. Adding Functionality with the KeyDown Event
        2. Loading the Grid
      6. Formatting Input in Visual Basic .NET
    6. Innovative Screen Design
      1. Extending Screen Design in Visual FoxPro
        1. The Windows Design Guide
        2. The Quicken Interface
      2. The Quicken Interface in Visual Basic .NET
      3. The FoxPro Grid
      4. Buttons That Load a Different Form
      5. SDI Forms
      6. Colors
      7. Colors in Form Controls
      8. Text Color on Command Buttons, Radio Buttons, and Check Boxes
      9. Colors on Graphical Style Controls
      10. User-Settable Form Size and Location
      11. Grids Redux
      12. Tree Views and Lists in FoxPro
      13. Build Your Own Menu
      14. ActiveX Controls
      15. Build Your Own Controls
    7. Tools
    8. Summary
  14. 9. Searching and Filtering in Visual FoxPro and Visual Basic .NET
    1. Record Filtering in FoxPro
    2. Record Filtering in Visual Basic .NET
    3. A Generic Record Lookup Grid with Column Sorting in Visual FoxPro
    4. Returning a Value from a Visual Basic .NET Form
    5. Using the DefaultDataView for Filtering and Sorting
    6. A Generic Record Lookup Form in Visual Basic .NET
    7. Minimalist Filtering in Visual FoxPro and Visual Basic .NET
    8. Search Forms with Additional Fields
      1. A Generic Search Form in Visual FoxPro
      2. Building the EasySearch Form Class in Visual Basic .NET
        1. Using the Visual Basic .NET EasySearch Form Class
        2. What Can Possibly Go Wrong?
    9. Building Self-Populating Controls
    10. Cleaning Up Mistakes in Legacy Data to Improve Searching
      1. Migrating Legacy FoxPro Data to SQL Server
        1. Migrating to SQL
        2. Cleaning Up the Data
        3. Running the Data Conversion in Batch Mode
        4. Running the Conversion
        5. Data Cleanup: Conclusion
    11. Getting Filtered Data Across the Web
      1. Building a Parameterized Web Service in Visual FoxPro
      2. Using the DLL
      3. Using the Web Service in a Smart Client Application
      4. Building a Parameterized Web Service in Visual Basic .NET
    12. Summary
  15. 10. Reporting
    1. Reporting in Visual FoxPro
      1. Internal Details
      2. Report Layout in FoxPro
      3. Page Setup
        1. Printer Problems
      4. Report Controls
      5. Title and Summary Bands
      6. Data Grouping
      7. Variables
      8. A Simple Example
      9. Adding Groupings
      10. Calculated Expressions
      11. Grouping Using a Report Variable
      12. Report Filtering
      13. Build and Execute a SELECT Statement in the Init Event of the Report's Data Environment
      14. Using a Report Filter with SQL Server
      15. Printing Tricks
      16. Generic Reporting
      17. Reporting on the Internet
      18. Exporting to a PDF
    2. Crystal Reports in Visual FoxPro
    3. Reporting in Visual Studio .NET
      1. Building Your First Report with Visual Studio .NET
      2. Adding Login Information
      3. Putting the User in Control
      4. Report Management and Use with the Server Explorer
      5. Using a Dataset as a Data Source
      6. How It Works
      7. Report Filtering with Parameters
      8. Creating a Parameterized Report
        1. Adding a Parameter
      9. Using the Parameter
      10. XML Report Web Services
      11. Building ASP.NET Reporting Clients
      12. Exporting to a PDF
      13. Other Report Experts
        1. The Form Letter Wizard
        2. The Cross-Tab Expert
      14. The Drill Down Expert
    4. Summary

Product information

  • Title: Visual FoxPro to Visual Basic® .NET
  • Author(s):
  • Release date: May 2004
  • Publisher(s): Sams
  • ISBN: None