如何使用C#连接到Clusterpoint数据库
本文关键字:Clusterpoint 数据库 连接 何使用 | 更新日期: 2023-09-27 18:25:04
我已经下载了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;
}
如果您已经创建了Clusterpoint v4数据库,那么您只能使用REST来连接到数据库并执行命令,因为Clusterpoint v4目前只提供REST API。在Clusterpoint文档中可以找到v4的连接代码示例:https://www.clusterpoint.com/docs/?page=5-连接&版本=4
如果您计划创建v3数据库,那么您可以下载适当的.NET API库,并遵循以下示例:https://www.clusterpoint.com/docs/?page=5-连接&language=.NET&版本=3