Santhakumar Munuswamy
Santhakumar Munuswamy

Reputation: 548

Contact Points value are missing in connection string using Cassandra

I have working with Cassandra and tried to connect a database in Cassandra but it is getting an error such as "System.FormatException' occurred in Cassandra.dll but was not handled in user code" and addition information as Contact Points value are missing in the connection string. Can you look at my connectivity code as below

HomeController

public class HomeController : Controller
    {
        //CqlConnection cqlConnection = new CqlConnection();
        private string conString = ConfigurationManager.ConnectionStrings["CassandraConnString"].ToString();

        // GET: Home
        public ActionResult Index()
        {
            using (CqlConnection cqlConnection = new CqlConnection(conString))
            {                
                cqlConnection.Open();
            }


            return View();
        }
    }

WebConfig

 <connectionStrings>
    <add name="CassandraConnString" connectionString="Database=StudentMaster;Port=9042;Server=127.0.0.1;"/>
  </connectionStrings>

Could you please advise to solve the connectivity issue and please let me know your idea.

Upvotes: 0

Views: 1532

Answers (1)

medvekoma
medvekoma

Reputation: 1181

Your connection string should look similar to this:

Contact Points=127.0.0.1;Default Keyspace=StudentMaster

You can check the available connection string elements here: https://github.com/datastax/csharp-driver/blob/master/src/Cassandra/CassandraConnectionStringBuilder.cs

Upvotes: 3

Related Questions