准备工作:
下载并引用Oracle.ManagedDataAccess.Client
控制台测试程序
class Program
{
static void Main(string[] args)
{
string constr = @"User Id=zftest;Password=123456;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.16.84)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))";
DataSet ds = OracleHelper.ExecuteDataset(constr, CommandType.Text, "select *from dba_users");
DataTable dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
Console.WriteLine(dt.Rows[i][j]);
}
Console.WriteLine("\n");
}
//int a= OracleHelper.ExecuteNonQuery(constr, CommandType.Text, "select *from dba_users");
int b = 0;
}
}