使用Cassandra

时间:2016-07-12 04:39:05

标签: c# .net asp.net-mvc cassandra

我与Cassandra合作并尝试连接Cassandra中的数据库,但是收到错误,例如" System.FormatException' occurred in Cassandra.dll but was not handled in user code"和Contact Points value are missing in the connection string的附加信息。你能看一下我的连接代码,如下所示

的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>

请您解决连接问题,请告诉我您的想法。

1 个答案:

答案 0 :(得分:2)

您的连接字符串应类似于:

Contact Points=127.0.0.1;Default Keyspace=StudentMaster

您可以在此处检查可用的连接字符串元素: https://github.com/datastax/csharp-driver/blob/master/src/Cassandra/CassandraConnectionStringBuilder.cs