오라클 설치 후 scott(연습 계정)을 언락을 풀으시고 진행하시면 됩니다.
SQL Plust 실행.
로그인 창이 뜨는데 사용자 이름에 scott를 입력하시고 암호는 오라클 설치 때 정해두신 암호를 적어주시면 됩니다.
접속을 했습니다.
이제 member 라는 테이블을 만들고 테이블에 데이터를 넣어보겠습니다.
name과 age를 가지고 있는 MEMBER 테이블을 생성.
테이블에 데이터를 넣었습니다.
데이터가 잘 들어가신 것을 확인할 수 있습니다.
필수!!
이제 비쥬얼 스튜디오 2010에서 DB 연결을 해봅시다.
소스
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using
using System.Data;
using Oracle.DataAccess.Client;
namespace orclTest
{
class Program
{
static void Main(string[] args)
{
// 오라클DB 계정, 비밀번호
string oradb = "User Id=scott;Password=eodowl;Pooling=false;Data Source=;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
string sql = "SELECT * FROM member";
OracleCommand cmd = new OracleCommand(sql, conn);
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Console.WriteLine(dr[0].ToString());
Console.WriteLine(dr[1].ToString());
}
conn.Close();
conn.Dispose();
}
}
}
실행화면.
'프로그래밍 > .NET' 카테고리의 다른 글
| ref, out 키워드 (0) | 2012.08.02 |
|---|---|
| 프로퍼티 SET/GET (0) | 2012.08.01 |
| 프로그램 제어(핸들값 이용) (0) | 2012.07.26 |
| 핸들값 (0) | 2012.07.26 |
| Alert창 (0) | 2012.07.25 |