ADO 연결 시 0X80004002
ADO 연결 시 다음과 같은 코드에서 0X80004002 에러를 리턴한다.
hr = pConnection.CreateInstance(__uuidof(Connection));
if(FAILED(hr))
{
CString strError;
strError.Format(_T("Error creating connection hr = %x\n"), hr);
OutputDebugString(strError);
}
이전에 잘되던 코드라 정말 이상해서 저렿게 에러를 찍었는데 0X80004002 리턴값이....
이곳에 해당 오류에 대한 설명이 되어있다.
http://support.microsoft.com/kb/2517589
ADO 응용 프로그램이 실행 되는 Windows 7 s P 1 이나 Windows Server 2008 R2 s P 1 이나 KB983246 설치 되어 있는 컴퓨터에서 다시 컴파일한 후 하위 수준 운영 체제에서 실행 되지 않습니다.
라고 되어 있다. 내 PC 는 WINDOWS7SP1 이고 여기서 컴파일 한 후 WINDOWS2003 에서 실행 하니 안되는 것 이었다.
정상동작 하게 하려면 2가지 방법이 있다.
첫째, Windows 7 s P 1 이나 Windows Server 2008 R2 s P 1 이나 KB983246 가 설치 되지 않은 PC에서 컴파일 한다.
두번째는 다음과 같다.
자신에 맞는 파일 다운로드 http://support.microsoft.com/kb/2640696
32bit
다운로드 후에는 종전에 import 방식을 변경한다.
#import "C:\Program Files\Common Files\System\ado\msado15.dll" rename("EOF", "EndOfFile")
이렇게 썼던것을
#import "c:\program files\common files\system\ado\msado60_Backcompat_i386.tlb" rename("EOF","EndOfFile")
만약 namespace 를 안쓴다면
#import "c:\program files\common files\system\ado\msado60_Backcompat_i386.tlb" no_namespace rename("EOF","EndOfFile")
으로 변경 한다.
이렇게 한 후 windows7 에서 컴파일 하여 2003에 적용하니 잘된다.
오늘도 삽질 완료~