using System;
using System.Data;
using System.Data.OracleClient;
class Class1{
static void Main(string[] args)
{
string connstr = "User Id=scott; Password=tiger; Data Source=oranet";
OracleConnection con = new OracleConnection(connstr);
con.Open();
string sql = "select empno, ename from emp";
OracleCommand cmd = new OracleCommand(sql, con);
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Console.Write(dr[0].ToString() + "\t");
Console.Write(dr[1].ToString() + "\t");
Console.Write(dr[2].ToString() + "\t");
Console.WriteLine(dr[3].ToString());
}
// close and dispose the objects
dr.Close();
dr.Dispose();
cmd.Dispose();
con.Close();
con.Dispose();
}
}
|