首先要安装ODAC并配置环境变量
项目中添加引用【Oracle.DataAccess】
code:
using Oracle.DataAccess.Client;
public void Execute()
{
OracleConnection conn = new OracleConnection(connString);
try
{
conn.Open();
string sql ="SELECT * FROM T1";
OracleCommand cmd = new OracleCommand(sql, conn);
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
catch (Exception ex)
{
WriteLog(ex.Message);
}
finally
{
conn.Close();
}
}
}
时间: 2024-10-25 04:35:07