1 / 12

ADO 라이브러리 사용 방법

ADO 라이브러리 사용 방법. 최흥배 Twitter : @jacking75. 현재 개발 중입니다 . 목적은 C++11 지원 및 병렬 프로그래밍 지원입니다. CREATE TABLE [ dbo ].[Test_Temp2]( [ID] [ nvarchar ](50) NOT NULL, [ UserCode ] [ int ] NOT NULL, [ Lv ] [ int ] NOT NULL, [Money] [ bigint ] NOT NULL ) ON [PRIMARY].

Download Presentation

ADO 라이브러리 사용 방법

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ADO 라이브러리 사용 방법 최흥배 Twitter : @jacking75 현재 개발 중입니다. 목적은 C++11 지원 및 병렬 프로그래밍 지원입니다.

  2. CREATE TABLE [dbo].[Test_Temp2]( [ID] [nvarchar](50) NOT NULL, [UserCode] [int] NOT NULL, [Lv] [int] NOT NULL, [Money] [bigint] NOT NULL ) ON [PRIMARY]

  3. http://cafe.naver.com/ongameserver/3412

  4. 이 라이브러리는 김영찬님이 만든 것으로 ‘온라인 서버 제작자 모임’ 카페에서 공개했던 라이브러리입니다. ( http://cafe.naver.com/ongameserver.cafe ) 김영찬님의 동의를 얻어서 HalfNetwork의 외부 라이브러리로 제공되었습니다. 문서가 부실합니다. 그러나 코드를 보면 이해하는데 크게 어려움은 없으리라 생각합니다. 개인적인 생각으로는 이 라이브러리를 사용할 때는 사용하는 프로젝트에 맞게 수정 하는 것이 좋다고 생각합니다.

  5. 라이브러리 파일 VC++10으로 만들어진 ADOLib프로젝트는 ADO 라이브러리와 예제가 같이 있습니다. 파일 중 Lock.h Unidef.h ado.cpp ado.h AdoManager.h 파일만이 ADO 라이브러리 파일입니다. ‘ADO_Test.txt’ 파일에는 예제 코드가 있습니다. 꼭 참고하세요

  6. Tutorial

  7. 예제 1. 설정 SAdoConfigadoconfig; adoconfig.SetIP(_T("localhost\\TEST")); // 디비 주소 adoconfig.SetUserID(_T("sa")); // 아이디 adoconfig.SetPassword(_T("dev")); // 패스워드 adoconfig.SetInitCatalog(_T("TEST")); // 디비 이름 adoconfig.SetConnectionTimeout(3); adoconfig.SetRetryConnection(true); adoconfig.SetMaxConnectionPool(3); CAdoManager* pAdomanager = new CAdoManager( adoconfig );

  8. 예제 1. 일반 SELECT 쿼리문 CAdoManager* pAdomanager = new CAdoManager(adoconfig); CAdo* pAdo = NULL; { CScopedAdoscopedado(pAdo, pAdomanager, false); pAdo->SetQuery(_T("SELECT UID, PWD FROM Users WHERE ID='jacking'")); pAdo->Execute(adCmdText); if(!pAdo->IsSuccess()) { std::wcout << L"쿼리문 실패" << std::endl; return 0; } intnUID = 0; WCHAR szPWD[16]; if(!pAdo->GetEndOfFile() ) { pAdo->GetFieldValue(_T("UID"), nUID); pAdo->GetFieldValue(_T("PWD"), szPWD, 16); } else { std::wcout << L"jacking은 없습니다" << std::endl; return 0; }

  9. 예제 2. 일반 INSERT 쿼리문1 CAdoManager* pAdomanager = new CAdoManager(adoconfig); CAdo* pAdo = NULL; { CScopedAdoscopedado(pAdo, pAdomanager, false); pAdo->SetQuery( _T("Insert Into Users Values( 'jacking2', '1111' )") ); pAdo->Execute(adCmdText); if( !pAdo->IsSuccess() ) { std::wcout << L"쿼리문 실패" << std::endl; return 0; } else { std::wcout << L"쿼리문 성공" << std::endl; }

  10. 예제 3. 일반 INSERT 쿼리문2 트랜잭션 설정 CAdoManager* pAdomanager = new CAdoManager(adoconfig); CAdo* pAdo = NULL; { CScopedAdoscopedado(pAdo, pAdomanager, true); pAdo->SetQuery( _T("Insert Into Users Values( 'jacking3', '1111' )") ); pAdo->Execute(adCmdText); if( !pAdo->IsSuccess() ) { std::wcout << L"쿼리문 실패" << std::endl; return 0; } else { std::wcout << L"쿼리문 성공" << std::endl; } pAdo->SetCommit(true); true 에 의해서 commit 된다

More Related