일하다가 막혔던것들/C#(VB6)

VB6 ADODB.Connection 서버 네트워크 체크 방법

about_blank_i 2022. 8. 26. 11:52

오프라인에서도 프로그램이 동작할 수 있도록, 서버연결 및 네트워크 체크하는 로직이 필요했다.

1. 인터넷이 끊긴 경우, db 서버로 "select 1"과 같은 의미없는 조회 쿼리를 날려 현재 인터넷의  on/off 상태를 체크할 수 있다.

2. 인터넷은 정상인데,  db 서버 자체에 문제가 발생한 경우, ConnectionTimeout / CommandTimeout 과는 별개로 30초 이상의 시간이 소요된다. 

 

객체.Open options:=adAsyncExecute
* adAsyncExecute  : 호출이 완료되는것을 기다리지 않고 바로 콜백해버리는 옵션

https://documentation.help/ADO210/mdcstexecuteoptionenum.htm

 

ExecuteOptionEnum - Microsoft ActiveX Data Objects (ADO) Documentation

ExecuteOptionEnum Specifies how a provider should execute a command. Constant Value Description adAsyncExecute 0x10 Indicates that the command should execute asynchronously. adAsyncFetch 0x20 Indicates that the remaining rows after the initial quantity spe

documentation.help