我正在尝试从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驱动程序 管理器]未找到数据源名称且未指定默认驱动程序'。
答案 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();