Product Documentation

c-treeDB API for C#

Previous Topic

Next Topic

Command-Line Compile - Windows Developer Command Prompt

This section explains the steps to compile and run the c-treeDB C# tutorials from the Microsoft Visual Studio Developer Command Prompt (also called the Native Tools Command Prompt) on Microsoft Windows.

  • This tutorial requires that you have installed the Microsoft Windows SDK, available from Microsoft Windows SDK.
  • FairCom currently supports the 2015, 2017, and 2019 versions of Microsoft Visual Studio.
  • If the FairCom Database Engine server is not already running on your machine, start the server. See Starting the FairCom Database Engine.
  1. Open the Developer Command Prompt window for your version of Microsoft Visual Studio. Typically, this is available from the Start menu, selecting menu options similar to:

    Visual Studio 2017 > X64 Native Tools Command prompt for VS 2017

    Where 2017 is your version of Visual Studio and X64 is for a 64-bit version of c-tree (note “64” in the name of the default installation directory) or X86 for a 32-bit version of c-tree.

    Warning - If the Developer Command Prompt entry in the Start menu does not specify a bit depth, it will open the 32-bit version of the Developer Command Prompt, which is not correct for FairCom Database Engine.

    For more details, see the Microsoft Developer Command Prompt web page.

  2. In the Developer Command Prompt window, move to the drivers\csharp.nav\tutorials\cmdline directory and execute the BuildTutorials.bat file.

    This batch file will determine the version of the Microsoft C compiler you are using and will set the internal paths accordingly. It will then compile all the tutorials included for this driver.

    After all the tutorials have been built, the batch file will run them one-at-a-time. A prompt will ask you to press <Enter> before running each tutorial.

    If you see a c-tree error, you can look it up in the Error Code Reference. See the "Troubleshooting" section below for solutions to common problems.

The output from the Visual Studio debugger should look similar to the text below:

INIT

Logon to server...

DEFINE

Open table...

Add fields...

Create table...

MANAGE

Delete records...

Add records...

Display records...

1000 Bryan Williams

1001 Michael Jordan

1002 Joshua Brown

1003 Keyon Dooling

DONE

Close table...

Logout...

Press <ENTER> key to exit . . .

Executing the Tutorials by Hand

You can run the tutorials individually using the executables located in drivers\csharp.nav\tutorials\cmdline.

Tutorial1.exe

Tutorial2.exe

Tutorial3.exe

Tutorial4.exe

Running in Debug Mode

To fully observe this API in action, you can single-step through the code with the Visual Studio integrated debugger. You can call this as follows:

devenv Tutorial1.exe

devenv Tutorial2.exe

devenv Tutorial3.exe

devenv Tutorial4.exe

Hint: A better way to single-step and debug is to open the Visual Studio solution that we provide. See Compile Using Microsoft Visual Studio IDE.

Troubleshooting

This section lists some of the errors that can occur when compiling and running these tutorials:

cl.exe not found! Please set environment for Visual C/C++ compiler.

The most common cause of this error is running the BuildTutorials.bat file from a DOS shell or normal Windows command shell rather than from the Visual Studio Developer Command Prompt window.

ERROR: [133] - c-tree logon error.

The most common cause of these errors is that the FairCom Database Engine is not running on your machine. Remember that the c-tree evaluation license times out after 3 hours, so the server might have exited and needs to be restarted. See Starting the FairCom Database Engine.

TOCIndex