Product Documentation

FairCom C# Stored Procedures

Previous Topic

Next Topic

Quick Start - .NET Development

About .NET Stored Procedures

Microsoft .NET framework provides a common runtime functionality for Windows applications. This allows a consistent and comprehensive programming model for Windows developers. Extending platform flexibility for Windows developers, FairCom supports stored procedures, user-defined functions, and triggers within the .NET framework.

Key Features

  • SP, UDF, and triggers can be written in any language that compiles to a CLI
  • Exposes SQL classes similar to ADO
  • Client-side debugging or attach to the server.
  • Support for Visual Studio 2010 and later (up to 2017). Support for VS 2019 is being developed.

With this .NET support, your Visual Studio IDE can be used to create, edit, and debug SPs, UDFs, and triggers. An API is provided along with Visual Studio templates for complete .NET integrated development. Compile on your client and deploy binaries to your server. Both C# and Visual Basic templates are provided.

A solution file, containing two tutorials that follow our standard FairCom tutorial model, is provided in:


Visual Studio Extension

To aid in developing stored procedures (SP), user-defined functions (UDF), and triggers, FairCom provides a “c-tree Stored Procedure” extension to the Visual Studio IDE.

  • Note that C# .NET stored procedures are available on Microsoft Windows platforms only. If you wish to use stored procedures on other platforms, Java can be used for the stored procedures. See Java Stored Procedures.
  • Note that the two C# stored procedure tutorials FairCom provides are not executables which can be launched from the command-line, like most of the c-tree tutorials are. Instead, these tutorials must be installed into the database from within the Visual Studio IDE and then can be tested from within the Visual Studio IDE.
  • The .NET Framework 4.0, available from Microsoft, is required for writing SP, UDF, and triggers.

Prerequisite - Configure Microsoft Visual Studio Properly

Be sure Microsoft Visual Studio is configured properly. For Visual Studio 2017 and 2019 to be able to build the tutorials, the .NET desktop development workload needs to be installed as part of Visual Studio. In Visual Studio 2017 and 2019, click Tools > Get Tools and Features, which runs the Visual Studio installer. If the installer requires an update before it will run, allow that update. Find the .NET desktop development workload under the Windows group and make sure it is checked, as shown here:

If it is not already checked, give it a check mark and then click the MODIFY button to install that workload. This ensures that all of the tools needed to build and run these tutorials are installed.

Note that Visual Studio 2015 does not have this prerequisite.

c-tree Stored Procedure Extension Installation

FairCom distributes VSIX package installers which install the c-tree Stored Procedure extension into Microsoft Visual Studio. These installers have been updated to support the latest versions of Visual Studio 2012, 2015, 2017, and 2019. Users with prior versions should uninstall their existing plugin (following the instructions below) and install the new version for the latest compatibility. To install this extension, navigate to the drivers\csharp.sql.storedprocs folder with Windows Explorer, and then double-click the .vsix file that matches your version of Visual Studio.

This will launch the VSIX Installer. Give it permission to run and make changes, and then click the Install button when you see a window like the following appear:

The install process may download and install one or more .NET Frameworks, so it’s important to be connected to the Internet while running this installer. Note that the install process can take several minutes. When the installation is complete, you should see a window like this:

This window is asking you to close Visual Studio (if it’s open) and then restart it, in order for the changes to take effect. In other words, it is asking you to “reboot” Visual Studio.

  • Note that this extension must be installed into Visual Studio before you load the solution file that contains the c-tree Stored Procedure tutorials.
  • Note also that this extension should be installed with Visual Studio not running.

Extension Removal

Should you need to remove this extension, launch Visual Studio. From within Visual Studio, do the following:

  • VS 2015 and 2017 - Go to the Visual Studio Tools menu and select Extensions and Updates.
  • VS 2019 - Go to the Extensions menu and select Manage Extensions.

All versions of VS - Next, make sure Installed is selected on the left, locate the c-tree Stored Procedure item template, and click Uninstall, as shown below. Note that the search tool is useful for finding the c-tree item.

Clicking the Uninstall button will schedule the extension for un-installation. To make the un-install actually happen, exit Visual Studio. This will cause the VSIX Installer to run. Give it permission to run and then click the Modify button when asked.

Note that the uninstall process can take several minutes.