C#/C# WPF 실무
[C# WPF] Oracle DB연동하기
냠냠쿠
2023. 9. 7. 11:47
728x90
📌 너겟 설치
📌 전역변수에 DB 문자열 입력
// DB연결 문자열
string oradb = "Data Source="
+ " ( DESCRIPTION ="
+ " ( ADDRESS_LIST ="
+ " ( ADDRESS = (PROTOCOL = TCP)(HOST = 아이피주소)(PORT = 포트번호)) )"
+ " ( CONNECT_DATA ="
+ " ( SERVER = DEDICATED )"
+ " ( SERVICE_NAME = 서비스이름 ) ) );"
+ " User Id= 아이디;"
+ " Password = 비번;";
📌 DB 연결 및 쿼리문 입력
...
using (var _connection = new OracleConnection(oradb))
{
//sql 실행
_connection.Open();
//명령 객체 생성
OracleCommand cmd = new OracleCommand();
cmd.Connection = _connection;
//sql문 지정 및 실행
cmd.CommandText = xmlQuery;
cmd.ExecuteNonQuery();
...
쿼리문dms xmlQuery에 담아두었음
참고 게시글 :
[C# WPF] 다른 프로젝트에 있는 XML을 String 형태로 가져오기
📌 xml 파일 경로 넣어주기 namespace Query.OSPP { public class QueryPath { public string xmlQueryPath() { string _path = Path.Combine(HttpContext.Current.Server.MapPath("").Replace("\\Model.Service", ""), "Query.OSPP"); return _path; } } HttpConte
sm-lee2026210.tistory.com
💌 Reference
- https://csksoft.tistory.com/90
- https://www.csharpstudy.com/Practical/Prac-oracle.aspx
728x90