using System;
using System.Data;
using System.Data.OleDb;
class Sample
{
public static void Main()
{
string ConStr = ("Provider=MSDAORA;data source=oraclejava;User ID=scott;Password=tiger");
OleDbConnection Conn = new OleDbConnection(ConStr);
OleDbDataAdapter thisAdapter = new
OleDbDataAdapter("select * from emp", Conn);
OleDbCommandBuilder thisBuilder = new OleDbCommandBuilder(thisAdapter);
Console.WriteLine("SELECT Command :\n{0}\n",
thisAdapter.SelectCommand.CommandText);
OleDbCommand updateCommand = thisBuilder.GetUpdateCommand();
Console.WriteLine("UPDATE Command :\n{0}\n",
updateCommand.CommandText);
OleDbCommand insertCommand = thisBuilder.GetInsertCommand();
Console.WriteLine("INSERT Command :\n{0}\n",
insertCommand.CommandText);
OleDbCommand deleteCommand = thisBuilder.GetDeleteCommand();
Console.WriteLine("DELETE Command :\n{0}",
deleteCommand.CommandText);
Conn.Close();
}
}
==============================================================
[결과]
SELECT Command :
select * from emp
UPDATE Command :
UPDATE EMP SET EMPNO = ? , ENAME = ? , JOB = ? , MGR = ? , HIREDATE = ? , SAL =
? , COMM = ? , DEPTNO = ? WHERE ( (EMPNO = ?) AND ((? IS NULL AND ENAME IS NULL)
OR (ENAME = ?)) AND ((? IS NULL AND JOB IS NULL) OR (JOB = ?)) AND ((? IS NULL
AND MGR IS NULL) OR (MGR = ?)) AND ((? IS NULL AND HIREDATE IS NULL) OR (HIREDAT
E = ?)) AND ((? IS NULL AND SAL IS NULL) OR (SAL = ?)) AND ((? IS NULL AND COMM
IS NULL) OR (COMM = ?)) AND ((? IS NULL AND DEPTNO IS NULL) OR (DEPTNO = ?)) )
INSERT Command :
INSERT INTO EMP( EMPNO , ENAME , JOB , MGR , HIREDATE , SAL , COMM , DEPTNO ) VA
LUES ( ? , ? , ? , ? , ? , ? , ? , ? )
DELETE Command :
DELETE FROM EMP WHERE ( (EMPNO = ?) AND ((? IS NULL AND ENAME IS NULL) OR (ENAM
E = ?)) AND ((? IS NULL AND JOB IS NULL) OR (JOB = ?)) AND ((? IS NULL AND MGR I
S NULL) OR (MGR = ?)) AND ((? IS NULL AND HIREDATE IS NULL) OR (HIREDATE = ?)) A
ND ((? IS NULL AND SAL IS NULL) OR (SAL = ?)) AND ((? IS NULL AND COMM IS NULL)
OR (COMM = ?)) AND ((? IS NULL AND DEPTNO IS NULL) OR (DEPTNO = ?)) )
댓글 없음:
댓글 쓰기