Unspecified Error 80004005 - ADO Connection

Unspecified Error 80004005 - ADO Connection

Post by Adam » Sat, 18 Oct 2003 23:33:45


Hello All,

Please can someone tell me what might be wrong with the
following code!? I'm compiling with Visual Studio .NET,
using Windows XP, which appears to have MDAC 2.7, and the
DSN and Database appear to be fine. Error is 80004005
Unspecified Error.

Thanks!

#import "c:\Program Files\Common
Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x)
_com_issue_error(x);};
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

struct InitOle {
InitOle() { ::CoInitialize(NULL); }
~InitOle() { ::CoUninitialize(); }
} _init_InitOle_;

void Load_Data(Struct_OptData *pE04Data, Constraint_Data
*pCData)
{
HRESULT hr = S_OK;
_bstr_t strCnn("Data Source='MyDSN';");

_ConnectionPtr pConnection = NULL;

try
{
// Open a connection.
TESTHR(pConnection.CreateInstance(__uuidof
(Connection)));
pConnection->Open
(strCnn,"","",adConnectUnspecified);