## [C#] 오라클 컨넥션 만들기!! 코딩정보/C# 2019-06-12 08:20:09 * * * using System; using System.Data; using System.Data.OleDb; class TableAnalysis { static void Main(string[] args) { string sql = "Provider=MSDAORA.1;Password=tiger;User ID=scott;Data Source=noaa;Persist Security Info=True"; //oracle 서버 연결 OleDbConnection conn = new OleDbConnection(sql); //conn.ConnectionString = sql; try { conn.Open(); //데이터베이스 연결 OleDbCommand cmd = new OleDbCommand(); cmd.CommandText = "select * from member"; //member 테이블 cmd.CommandType = CommandType.Text; //검색명령을 쿼리 형태로 cmd.Connection = conn; OleDbDataReader read = cmd.ExecuteReader(); //select * from member 결과 Console.WriteLine("***** 테이블 분석 결과 *****"); for (int i = 0; i < read.FieldCount; i++) { Console.WriteLine("필드이름 : {0} \n", read.GetName(i)); } Console.WriteLine("총필드 개수는" + read.FieldCount); read.Close(); } catch (Exception ex) { Console.WriteLine("에러발생{0}", ex.Message); } finally { if (conn != null) { conn.Close(); //데이터베이스 연결 해제 Console.WriteLine("데이터베이스 연결 해제.."); } } } } #오라클 #서버 #connection #연결 #c# #server #ORCLE
(*No embedded English lines found. Add translations later.*)