找不到Clickhouse数据源名称,也没有默认驱动程序

时间:2018-06-15 14:37:14

标签: clickhouse

我正在尝试从c#+。net到odbc(clikhouse-odbc)进行连接。

以下是我的代码

var builder = new OdbcConnectionStringBuilder();
builder.Driver =
"E:\...\clickhouse-odbc-master\vs\x64\clickhouseodbc.dll";
builder.Add("SERVER", "....");
builder.Add("DATABASE", "default");
builder.Add("PORT", 8123);
builder.Add("FRAMED", 0);
var connection = new OdbcConnection("Driver = Click House ANSI; Host = ***; Port =***");
//Also tried below
//var connection = new OdbcConnection(builder.ConnectionString);
connection.Open();
return connection;

当我跑步时,我有例外:

  

System.Data.Odbc.OdbcException:' ERROR [IM002] [Microsoft] [ODBC驱动程序   管理器]未找到数据源名称且未指定默认驱动程序'。

我还安装了驱动程序并配置如下图所示 enter image description here

1 个答案:

答案 0 :(得分:0)

我必须添加builder.Driver,如下所示:

      var builder = new OdbcConnectionStringBuilder();
        builder.Driver =
            "E:\<path>\clickhouseodbc.dll";
        builder.Add("SERVER", "...");
        builder.Add("DATABASE", "default");
        builder.Add("PORT", 8123);
        builder.Add("FRAMED", 0);
        builder.Driver = "ClickHouse ANSI";
        var connection = new OdbcConnection(builder.ConnectionString);
        connection.Open();