using System;
//Oracle .Net Provider
using Oracle.DataAccess.Client;
//ADO.Net
using System.Data;
namespace ConsoleApplication1
{
class Class1
{
static void Main(string[] args)
{
string strSQL = "Select empno, ename, job from emp";
//Create the connection
OracleConnection oConn = new OracleConnection("Data Source=ORCL;User ID=SCOTT;Password = TIGER");
//Create the OracleCommand object to execute the query
OracleCommand oCmd = new OracleCommand(strSQL, oConn);
//The OracledataAdapter is opened to communicate the DataSet Object
OracleDataAdapter oDa = new OracleDataAdapter(oCmd);
//Create the DataSet object this is an ADO Object
DataSet adoDs = new DataSet();
//Open the connection
oConn.Open();
//The OracleDataAdapter fill the query results into the DataSet
oDa.Fill(adoDs, "emp");
oConn.Close();
//Display the Column Names
foreach (DataColumn dc in adoDs.Tables[0].Columns)
Console.Write("{0,14}", dc.ColumnName);
Console.Write("\n");
foreach (DataColumn dc in adoDs.Tables[0].Columns)
Console.Write("{0,14}", "-----------");
Console.Write("\n");
//Display the data
foreach (DataRow dr in adoDs.Tables[0].Rows)
{
for (int i = 0; i<adoDs.Tables[0].Columns.Count; i++)
Console.Write("{0,14}", dr[i]);
Console.Write("\n");
}
}
}
}
//Oracle .Net Provider
using Oracle.DataAccess.Client;
//ADO.Net
using System.Data;
namespace ConsoleApplication1
{
class Class1
{
static void Main(string[] args)
{
string strSQL = "Select empno, ename, job from emp";
//Create the connection
OracleConnection oConn = new OracleConnection("Data Source=ORCL;User ID=SCOTT;Password = TIGER");
//Create the OracleCommand object to execute the query
OracleCommand oCmd = new OracleCommand(strSQL, oConn);
//The OracledataAdapter is opened to communicate the DataSet Object
OracleDataAdapter oDa = new OracleDataAdapter(oCmd);
//Create the DataSet object this is an ADO Object
DataSet adoDs = new DataSet();
//Open the connection
oConn.Open();
//The OracleDataAdapter fill the query results into the DataSet
oDa.Fill(adoDs, "emp");
oConn.Close();
//Display the Column Names
foreach (DataColumn dc in adoDs.Tables[0].Columns)
Console.Write("{0,14}", dc.ColumnName);
Console.Write("\n");
foreach (DataColumn dc in adoDs.Tables[0].Columns)
Console.Write("{0,14}", "-----------");
Console.Write("\n");
//Display the data
foreach (DataRow dr in adoDs.Tables[0].Rows)
{
for (int i = 0; i<adoDs.Tables[0].Columns.Count; i++)
Console.Write("{0,14}", dr[i]);
Console.Write("\n");
}
}
}
}
12-27 | 1993 | |||
12-11 | 1459 | |||
53 | 03-15 | 1215 | ||
52 | 01-31 | 1377 | ||
51 | 01-31 | 1233 | ||
50 | 01-31 | 1067 | ||
49 | 01-19 | 1376 | ||
48 | 01-11 | 1211 | ||
47 | 01-03 | 1709 | ||
46 | 12-27 | 1993 | ||
45 | 12-19 | 1478 | ||
44 | 12-14 | 1445 | ||
43 | 12-11 | 1459 | ||
42 | 12-09 | 1174 | ||
41 | 12-01 | 1377 | ||
40 | 12-01 | 1534 | ||
39 | 12-01 | 1035 |
댓글 없음:
댓글 쓰기