Top
PowerCOBOL V11.0 Getting Started
FUJITSU Software

2.2.5 Constructing Sample Database

This chapter discusses constructing a sample database that is used in PowerCOBOL sample programs. SQL Server Express is available from the Microsoft Download Center.

SQL Server Express must be installed on the local machine with the instance name of "\SQLEXPRESS" in order to work with the sample programs.

Refer to the "NetCOBOL V11.0 User's Guide" >"Sample Database" about sample database tables.

The sample database can be used in the "NetCOBOL Getting Started" > "Using SQL with COBOL".

2.2.5.1 Creating Sample Database

In the case of using SQL Server Management Studio

The following steps describe how to create a sample database in SQL Server Express by using SQL Server Management Studio.

  1. Start SQL Server Management Studio and connect to SQL Server Express.

  2. Select the Open > File item in the File menu.

  3. Select "SampleDatabase\COBOLSample.sql" of the sample programs folder in the Open File dialog box.

  4. Click on the Execute button in the toolbar.

  5. Verify the "COBOLSample" database is created in Databases in the Object Explorer.

In the case of using the SQLCMD command in the system console (command prompt window)

The following steps describe how to create a sample database in SQL Server Express by using the SQLCMD command in the system console.

  1. Bring up the command prompt window.

  2. Move to the SampleDatabase folder in the sample program folder.

  3. Set the following command.

    sqlcmd -S .\SQLEXPRESS -E -i COBOLSample.sql
  4. Set the following command and check the contents of the stock table are displayed.

    sqlcmd -S .\SQLEXPRESS -E -d COBOLSample -Q "select * from STOCK"

2.2.5.2 Defining ODBC Source

Define the ODBC Source as follows from the ODBC Data Source Administrator window (bring up the Windows Control Panel and double-click the on the ODBC Data Sources item).

Driver

SQL Server

Data Source Name

COBOLSample

Server name

.\SQLEXPRESS

Default database

COBOLSample

The following steps describe how to operate in the ODBC Data Source Administrator window.

  1. Make sure the User DSN tab is open, and click on the Add button. The Create New Data Source dialog box is displayed.

  2. Select the SQL Server as a driver, and click on the Finish button. The Create New Data Source to SQL server dialog box is displayed.

  3. Enter COBOLSample for the Name and COBOL Sample Database for the description. And enter the server name for the Server in which COBOLSample database is created. If SQL Server Express is used, select .\SQLEXPRESS. Click on the Next button.

  4. Enter the login ID and the password if needed. If SQL Server Express is used, check the With Windows NT authentication using the network login ID is selected. Click on the Next button.

  5. Click on the Change the default database to checkbox, and select the "COBOLSample" database name. Click on the Next button and the Finish button.

  6. Click on the Test Connection button and check connected correctly. Click on the OK button.

  7. Click on the OK button.