Skip to content

Latest commit

 

History

History
94 lines (70 loc) · 3.52 KB

File metadata and controls

94 lines (70 loc) · 3.52 KB

ADO.NET Sample App

Overview

The Vertica ADO.NET driver provides a data source for Vertica, so a client can connect and read/write data. The driver is written in C# and built on .NET. The published version can be found on NuGet here.

See the available data types, commands, and other information here.

Prerequisites

  • .NET Core 3.1+, or .NET Framework 4.6.1+
  • A running Vertica database

ℹ️ Note that you will need to use .NET Core, not .NET Framework, if using Linux or Mac. It is recommended to use .NET 6.0 since it is a long-term support version.

Install .NET

Follow the instructions for Windows, Linux, or macOS.

Start a Vertica server

If you don't already have a Vertica instance running, it is recommended to use the Vertica Community Edition (CE) Docker image.

Start Vertica CE in Docker:

docker run -d \
    -p 5433:5433 -p 5444:5444 \
    -v vertica-data:/data \
    --name vertica-ce \
    --restart=unless-stopped \
    vertica/vertica-ce:latest

Build and run the ADO.NET sample app

  1. Modify the app.config connection string and query as needed (note that app.config is copied to the build directory as SampleApp.dll.config during the build)
  2. Build the application:
dotnet build
  1. Run the application:
dotnet run --framework net6.0

ℹ️ Note that the sample app produces binaries for multiple target .NET versions: .NET 6.0, .NET Core 3.1, and .NET Framework 4.6.2 (Windows only). The above example only shows .NET 6.0.

Referencing a pre-release build

If there is a pre-release version of the driver available on NuGet, you will need to reference the specific version in your project.

For example, to reference 24.1.0, modify the project file PackageReference as follows:

<ItemGroup>
  <PackageReference Include="Vertica.Data" Version="24.1.0" />
</ItemGroup>

Referencing a DLL

If you have the Vertica ADO.NET driver DLL, you can update the project to use the DLL directly:

  1. Copy the Vertica ADO.NET driver DLL (Vertica.Data.dll) to the lib folder
  2. Replace the existing packages reference in the project file with the following:
<ItemGroup>
  <Reference Include="Vertica.Data">
    <HintPath>lib\Vertica.Data.dll</HintPath>
  </Reference>
</ItemGroup>

<ItemGroup>
  <PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
  <PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
</ItemGroup>
  1. Build and run the application, same as above

Referencing a local NuGet package

If you have the Vertica ADO.NET driver NuGet package, you can update the project to use the package directly:

  1. Copy the Vertica ADO.NET driver NuGet package (Vertica.Data.<VERSION>.nupkg) to the packages folder
  2. Add the following to a nuget.config file in this directory:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <packageSources>
    <add key="LocalPackages" value="packages" />
  </packageSources>
</configuration>
  1. Update the Vertica.Data package reference version in the project file as needed
  2. Build and run the application, same as above