https://24b4dt1v60e526bo2p349l4c-wpengine.netdna-ssl.com/wp-content/themes/instaclustr-2020/assets/font/ionicons.ttf?v=2.0.0

Connect to Cassandra with C#

In this article, we will introduce how to connect to Cassandra by using C#. Firstly we will walk through installing and configuring a C# development environment and then provide simple examples for connecting, with and without TLS to the remote Cassandra server.

Please refer to our support documentation here for general information on connecting to your Cassandra Cluster first.

Download and install Visual Studio

Go to visualstudio to download and install Visual Studio.

Once installed create a new Console C# project.

Install Cassandra C# driver

Install Cassandra C# Driver using your choice of package manager, here is an example using NuGet.

manage nuget packages

In the search bar, search for and select NuGet package manager

Cassandra C Sharp Driver

Search for and install CassandraCSharpDriver in the NuGet Package manager window.​

If you unfold the Packages folder in the sidebar, you should now see CassandraCSharpDriver in the list of packages installed.

Connecting without TLS

Replace Program.cs with the following example.

Replace Public IP’s, Data Centre, username and password with your required configuration.

Run the code by clicking on the green arrow in the toolbar.

Write Sample Code​

The output should not have any errors and look something like this.

Connecting with TLS via windows

In order to connect to your TLS enabled cluster with C# please first contact our support with a request here.

After the connection has been enabled by us, TLS needs to configured on your client machine to connect to the cluster.

The CA certificates can be downloaded from your clusters Connection Info page.

Write Sample Code

Replace Program.cs with the following example.

Replace the public IP’s, username, password and path to your cluster-ca-certificate.der with your required configuration.

Run the code by clicking on the green arrow in the toolbar.

Need Support
Learn More

Already have an account?
Login to the Console

Experiencing difficulties on the website or console?
Status page for known incidents


Don’t have an account yet?
Sign up for a free trial

Why sign up?
To experience the ease of creating and managing clusters via the Instaclustr Console.