Tutorial: Web Application using SQL

Walks you through the creation of a Windows ASP.NET Web application that interacts with the BookDemo base application using SQL.

The project used in this tutorial includes a page that is generated in .NET COBOL. The page calls an intermediary class method to funnel all requests from the web page to a single routine. This encases the functionality within a run unit for isolation of resources, such as a database connection, for any function triggered from the Web page. The intermediary program maps .NET data types onto COBOL data types, and then calls the existing COBOL program to perform the work and access the database.


  • Review the Assumptions and Before you begin sections in the Tutorials: OpenESQL .NET Code topic to ensure that your environment is set up properly.
  • Before attempting this tutorial, you must first work through Tutorial: Prepare the SQL Server Environment.
  • The features demonstrated in this tutorial require that you have installed the Visual COBOL ASP.NET and Web Applications feature. If this feature is missing, see To install missing features from the IDE for installation instructions.

Demonstration solution - SQLBookDemoWebApplication

The SQLBookDemoWebApplication solution and project you create for this tutorial uses the following provided demonstration files in addition to the BookDemo base application:

In this tutorial, the sqlbook.cbl program is recompiled to .NET COBOL code without any changes. Recompiling the program exposes it as a class and exposes its main entry point as a static method. Its linkage section defines data as standard COBOL types, such as PIC X. Non-COBOL client programs do not understand these standard COBOL types. Therefore, you must map the standard COBOL types to .NET compatible types before communicating with the client program. This mapping is done by the SqlBookWrapper.cbl program.
In this tutorial, SqlBookWrapper program is recompiled as an intermediary class. This intermediary class is added as a project reference to the Web application project. In addition to acting as an interface between the client form and the business logic COBOL program, this program also wraps the business logic around a run unit for isolation of resources such as database connections.
The main Web form. You modify it to contain user input fields, output display fields, and a trigger button used to call the client program. Input and output fields are defined as text boxes.
This is the generated client COBOL program that is triggered by an end user click event initiated from the main Web form. When triggered, it:
  • Extracts the input data from text boxes on the form as System.Strings.
  • Calls the SqlBookWrapper program, passing it the string objects and receiving output as System.Strings.
  • Populates the text boxes on the form with the received System.Strings.
The application configuration file.
Note: The solution used in this tutorial is also provided with the Visual COBOL Samples Browser in completed form. To review the completed solution:
  1. Start the Visual COBOL Samples Browser. If you need instructions, see To start the Samples Browser.
  2. From the drop-down menu at the top of the Visual COBOL Samples Browser, select Show .NET only.
  3. In the left pane, click SQL.
  4. In the right pane, click OESQL - Web Application Book (.NET, VS).


To complete this tutorial, progress through these topics in the order presented here. The bottom of each topic provides Next topic and Previous topic navigational links to help you proceed in the proper sequence: