如何使用C#连接到Clusterpoint数据库?

时间:2015-11-29 02:12:25

标签: c# clusterpoint

我已经下载了API文件。我不知道如何执行与Clusterpoint数据库的连接。当我运行此代码时,我收到一条消息“连接字符串错误”。它还有助于提供一个有效的完整crud示例的参考。 THX。

string _url = @"https://api-eu.clusterpoint.com/v4";        //eu is correct
string _dbName = "db1";
string _username = "a@hotmail.com";                //not real
string _password = "...";                          //not real
string _document = "document";
string _documentID = "//document/id";
Dictionary<string, string> 
_dic = new Dictionary<string, string>(){ { "account", "0000" } };  //0000 not real

try
{
    CPS_Connection cpsConnection = new CPS_Connection(_url, _dbName, _username, _password, 
                                                      _document, _documentID, _dic);

    /* CPS_Connection cpsConnection = new CPS_Connection(
        "tcp://SERVER_IP:SERVER_PORT", "example", "username",        
        "password", "document",
        "/document/id", new Dictionary<string, string>() 
        { { "account", "<YOUR_ACCOUNT_ID>" } });
    */
}
catch (Exception e)
{
    Console.WriteLine("Connection Error...."+e.Message);
    Console.Read();
    return;
}

1 个答案:

答案 0 :(得分:1)

如果您已创建Clusterpoint v4数据库,那么您只能使用REST连接到数据库并执行命令,因为Clusterpoint v4当前仅提供REST API。 可以在Clusterpoint文档中找到v4的连接代码示例:https://www.clusterpoint.com/docs/?page=5-Connection&version=4

如果您打算创建v3数据库,那么您可以下载相应的.NET API库并按照以下示例进行操作:https://www.clusterpoint.com/docs/?page=5-Connection&language=.NET&version=3