标签:man using col nbsp table 调用 安装 ble client
需求:从一台Oracle数据库获取数据,本以为是很简单的事情,直接将原来的SqlClient换成OracleClient调用,结果远没自己想的简单。要么安装Oracle客户端,要么安装PLSQL。网上这方面搜索后,太多的文章,还要不停的去测试。最后找个引入外部类库的方式。这个DLL其实是Oracle为C#专门提供的,在它的官方也可以下载到(不过找起来很麻烦)。
这里我就把这个方案和dll分享给大家。
链接:https://pan.baidu.com/s/17saKNnBVyDvMbt1L8lSf6A
提取码:sr97
using Oracle.ManagedDataAccess.Client; //引入命名空间 private void button1_Click(object sender, EventArgs e) { string strSql = "select * from s_user"; DataTable dt = QueryDt(strSql); } //Oracle连接字符串 private static string strconn = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.30.0.37)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=EMES)));Persist Security Info=True;User ID=EMES_DEV;Password=EMES_DEV;"; private DataTable QueryDt(string sql) { using (OracleConnection conn = new OracleConnection(strconn)) { try { if (conn.State != ConnectionState.Open) { conn.Open(); } OracleDataAdapter adap = new OracleDataAdapter(sql, conn); DataTable dt = new DataTable(); adap.Fill(dt); return dt; } catch (Exception ex) { return null; } finally { conn.Close(); } } }
1 格式: 2 string strconn = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.30.0.37)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=EMES)));Persist Security Info=True;User ID=EMES_DEV;Password=EMES_DEV;"; 3 4 格式: 5 string strconn = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=远程服务器IP地址)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=远程服务器数据库服务名称)));Persist Security Info=True;User ID=数据库用户名;Password=数据库密码;";
标签:man using col nbsp table 调用 安装 ble client
原文地址:https://www.cnblogs.com/chenyanbin/p/11324614.html