Connect to Cassandra with C# sample code

Menu

In this article, we will introduce how to connect to Cassandra by using C#. We will start to install C# development environment and then provide simple demo code for connecting remote server (Cassandra) and local program.

Download Visual Studio Community

Go to visualstudio and choose Community Version to install.

Install Visual Studio

Follow the instructions and install.

Create a new project

 

Choose Console Project and click Next.

 

Enter Project Name and click Create

Install Cassandra C# driver

In the left side of your development window, Open Solution View and notice that there is a folder called Packages.

Right-click Packages and click Add Packages…

Find out CassandraCSharpDriver in the window, and click Add Package.

If you unfold the Packages folder, you will see that a list of libraries has been installed in your local project.

Write sample code

Replace public IP, username, and password with your real settings.

Click Run and Start without Debugging, we can see the result as the following

 

 

Site by Swell Design Group