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");
}
}
}
}
12-27 | 1795 | |||
12-11 | 1304 | |||
53 | 03-15 | 1050 | ||
52 | 01-31 | 1209 | ||
51 | 01-31 | 1008 | ||
50 | 01-31 | 904 | ||
49 | 01-19 | 1211 | ||
48 | 01-11 | 1071 | ||
47 | 01-03 | 1552 | ||
46 | 12-27 | 1795 | ||
45 | 12-19 | 1318 | ||
44 | 12-14 | 1311 | ||
43 | 12-11 | 1304 | ||
42 | 12-09 | 1049 | ||
41 | 12-01 | 1213 | ||
40 | 12-01 | 1423 | ||
39 | 12-01 | 927 |
댓글 없음:
댓글 쓰기