Click here to Skip to main content
11,715,491 members (86,471 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# .NET Apache

I would like to use Apache Cassandra database with help of cassandra-sharp to use it in C#. However, I have some problem with correctly referencing everything to ensure I can use Cassandra there.

I have found this article ( I have converted the code from VB to C# and it looks like everything is correctly converted, except three lines.

using CassandraSharp.MadeSimple;
using Apache.Cassandra;

It cannot find MadeSimple and Apache. (Other using statements are OK after adding reference to cassandra library).

CqlResult res = cluster.ExecuteCql(queryString);
CqlResults and ExecuteCql cannot be found.

Could you give me some guidelines where it may result from?
The rest of code is OK.

Thanks in advance!

PS I have posted comment to that article but as last comment was from February, it may be simply forgotten by tutorial's creator or it may require some time to get any response.

The full code is like this:

//using System;
//using System.Collections.Generic;
using System.Linq;
//using System.Text;

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using CassandraSharp;
using System.Text;
using CassandraSharp.Config;
using CassandraSharp.MadeSimple;
using Apache.Cassandra;
namespace CassandraSharpTest
    class Program
        //static void Main(string[] args)

        public static void Main()
            // Loading Cassandra configuration...
            ICluster cluster = ClusterManager.GetCluster("TestCassandra");
            // Define your query
            string queryString = "select * from table";
            //Execute your query in Cassandra
            CqlResult res = cluster.ExecuteCql(queryString);
            // Connection release
            // Get results. In this example integer, date and double types

        public int getId(byte[] value)
            byte[] buffer = new byte[value.Length];
            value.CopyTo(buffer, 0);
            int result = BitConverter.ToInt32(buffer, 0);
            return result;
        public DateTime getDate(byte[] value)
            byte[] buffer = new byte[value.Length];
            value.CopyTo(buffer, 0);
            long ticks = BitConverter.ToInt64(buffer, 0);
            System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
            dateTime = dateTime.AddMilliseconds(ticks);
            return dateTime;
        public double getDouble(byte[] value)
            byte[] buffer = new byte[value.Length];
            value.CopyTo(buffer, 0);
            double result = BitConverter.ToDouble(buffer, 0);
            return result;
Posted 18-Apr-13 9:38am
Sergey Alexandrovich Kryukov at 18-Apr-13 15:46pm
I'm not sure you referenced required assembly (or assemblies) at all. Did you? Do you know how to do it? Where do you have the Cassandra assemblies? In GAC or not?
johnyjj2 at 19-Apr-13 11:25am
thanks for your reply. The only what I have done was including in Solution Explorer in Referencews section CassandraSharp (cassandra-sharp-bin-2.3.2\CassandraSharp.dll). I use .NET Framework 4 Client Profile.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 518
1 Richard MacCutchan 300
2 Maciej Los 259
3 ManasKumarM 155
4 Frankie-C 125
0 Sergey Alexandrovich Kryukov 785
1 CHill60 415
2 Richard MacCutchan 405
3 Maciej Los 389
4 OriginalGriff 320

Advertise | Privacy | Mobile
Web03 | 2.8.150901.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100