C#과 Oracle 오라클 연동 :: DB연동[SSISO Community]
 
SSISO 카페 SSISO Source SSISO 구직 SSISO 쇼핑몰 SSISO 맛집
추천검색어 : JUnit   Log4j   ajax   spring   struts   struts-config.xml   Synchronized   책정보   Ajax 마스터하기   우측부분

DB연동
[1]
등록일:2008-04-04 11:41:45 (0%)
작성자:
제목:C#과 Oracle 오라클 연동
========오라클  접속===============================================

string  strConn  =  "Data  Source=서버이름;User  ID=id;Password=pass";
string  strQuery  =  "select  *  from  테이블명";

OracleConnection  oraconn  =  null;
OracleCommand  oracomm  =  null;
OracleDataAdapter  oraadp  =  null;

DataSet  ds  =  new  DataSet();  //  DataSet("test");로  해도  되고  안해도  되고
try
{
        oraconn  =  new  OracleConnection(strConn);

        oracomm  =  new  OracleCommand(strQuery,oraconn);  //  아래  두줄과  같은  내용
        //oracomm  =  oraconn.CreateCommand();
        //oracomm.CommandText  =  strQuery;

        oraadp  =  new  ORacleDataAdapter(oracomm);
        oraconn.Open();

        oraadp.Fill(ds,"테이블명");

        dataGrid1.DataSource  =  ds.Tables["테이블명"];  //  아래  두줄과  같은  내용
        //dataGrid1.DataSource  =  ds.Tables["ex"].Rows[0]["NAME"];
        //dataGrid1.DataSource  =  ds.Tables[0].DefaultView;

}
catch(Exception  ex)
{
        MessageBox.Show(ex.Message,"경고");
}
finally
{
        if  (dataadapter  !=  null)
        {
                dataadapter.Dispose();
        }

        if  (command  !=  null)
        {
                command.Dispose();
        }

        if  (connection  !=  null)
        {
                if  (connection.State  ==  System.Data.ConnectionState.Open)
                {
                        connection.Close();
                }
        connection.Dispose();
        }
}
[2008년  04월  04일  11:42:34  수정되었습니다.]
[본문링크] C#과 Oracle 오라클 연동
[1]
코멘트(이글의 트랙백 주소:/cafe/tb_receive.php?no=7176
작성자
비밀번호

 

SSISOCommunity

[이전]

Copyright byCopyright ⓒ2005, SSISO Community All Rights Reserved.