A number of ADO.NET demonstration projects are supplied in the Samples folder. See Start menu > All Programs > Micro Focus Visual COBOL 2010> Visual COBOL Samples.
Before you can use any of the demonstration projects, you need to set up the data sources used by the demonstrations. You can do this with the ADO.NET Connection Editor.
The OpenESQL demonstration projects all produce a console log displaying their progress and, possibly, query results. They all terminate on receipt of an error, after displaying an error message.
ConnectedDemo uses the SQL Server Northwind database. You must set up a connection to the Northwind database to run the ConnectedDemo project.
The ConnectedDemo.cbl program fills a DataSet from a data source, modifies the DataSet and then synchronizes the changes in the DataSet with the data source. The modified contents of the DataSet are displayed in the Output Window.
ConnectedDemo demonstrates three methods for refreshing server generated primary keys in a DataSet after rows are added; a statement batch, a separate TO REFRESH statement and a stored procedure with output parameters. ConnectedDemo also shows you how to synchronize changes in the DataSet with the data source using either the main DataSet or a separate DataSet which contains only changed rows. You could use the latter method to minimize network traffic in a distributed application.
You must set up a connection to the SQL Server Northwind database to run the CursorDemo project. This project demonstrates how to intermix OpenESQL with direct calls to ADO.NET.
The NoFetch.cbl program uses EXEC SQL to open a cursor and then EXEC ADO to fetch the results. The TestCursor.cbl program performs an EXEC SQL FETCH. The CursorDemo.cbl program populates a DataTable.
The DisconnectedDemo.cbl program manipulates offline data in a DataSet. The results of the data manipulation are displayed in the Output Window.
DisconnectedDemo demonstrates how to declare a DataSet from an XSD file generated by another project and how to load a DataSet from an XML file generated by another application.
This project shows how ADO.NET can be used in mixed language projects to insert and select large objects (LOBs). LobDemo shows OpenESQL working with LOB columns in a SQL Server table.
LOB columns are columns that can be up to 2GB in size. In this demo, the LOB columns are image columns and the OpenESQL object reference host variable.
The LobDemo.cbl program includes instructions for changing LobDemo to use DB2 UDB and BLOB columns.
The OrderStatusDemo project shows how ADO.NET can be used in mixed language projects. OrderStatusDemo uses COBOL and C#.
The netorderstatus.cbl program generates an XSD file from a DataSet declaration. The XSD file is then imported into the C# form. This simplifies building the user interface by enabling data binding with a strongly typed DataSet generated from the XSD file.
OrderStatusDemo also demonstrates the use of ADO.NET in legacy reuse not directly related to DBMS access. The data source used in this project is an existing COBOL subroutine.
The techniques used in this demo are applicable to CICS ECI transactions.