使用System.Data.OracleClient组件搭建Oracle数据库连接获取DataTable
使用System.Data.OracleClient组件搭建Oracle数据库连接获取DataTable
C# 全选
public DataTable GetDemoData()
{
var conn = System.Data.OracleClient.OracleClientFactory.Instance.CreateConnection();
conn.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.55)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=CSFRAMEWORKV6_SYSTEM)));User Id=test;Password=test123456;Pooling=true;Max Pool Size=512;Connection Lifetime=0;";
var cmd = System.Data.OracleClient.OracleClientFactory.Instance.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM \"tb_MyUser\"";
cmd.Connection = conn;
var adp = OracleClientFactory.Instance.CreateDataAdapter();
adp.SelectCommand = cmd;
DataSet ds = new DataSet();
adp.Fill(ds);
conn.Dispose();
return ds.Tables[0];
}
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网