标签:style class blog code http color
创建HANA的ODBC数据库连接。
默认在控制面板——》管理工具——》数据源(ODBC)
提示:如果系统是64位的,要运行 C:\Windows\SysWOW64\odbcad32.exe 中的32位的ODBC进行配置。


配置好ODBC之后,C#项目中使用:OdbcConnection连接
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 |
/// <summary>/// 根据SQL语句查询数据/// </summary>/// <param name="sql">SQL查询语句</param>/// <returns>结果集</returns>public
DataSet getDataSetBySql(String sql){ try { DataSet ds = new
DataSet(); OdbcCommand command = new
OdbcCommand(sql); //command 对象 String connstring = "dsn=ODBCNAME;uid=USERID;pwd=PASSWORD"; //ODBC连接字符串 using
(OdbcConnection connection = new
OdbcConnection(connstring)) //创建connection连接对象 { command.Connection = connection; connection.Open(); //打开链接 OdbcDataAdapter adapter=new
OdbcDataAdapter(command); //实例化dataadapter adapter.Fill(ds); //填充查询结果 return
ds; } } catch
(Exception ex) { throw
new Exception(ex.Message); }} |
C#通过ODBC查询HANA数据库数据,布布扣,bubuko.com
标签:style class blog code http color
原文地址:http://www.cnblogs.com/liluping860122/p/3772960.html