Pls help me. I want to use ADO to read records from MS Access 2003 in a DLL.

Dear all,
I want to use ADO to read records from MS Access 2003 in a DLL - a LSP DLL that would

be loaded by multithread. Here is my code:
BOOL WINAPI DllMain(IN HINSTANCE hinstDll, IN DWORD dwReason, LPVOID lpvReserved)
{
switch (dwReason)
{

case DLL_PROCESS_ATTACH:
hDllInstance = hinstDll;
//
// Initialize some critical section objects
//
InitializeCriticalSection(&gCriticalSection);
InitializeCriticalSection(&gOverlappedCS);
InitializeCriticalSection(&gDebugCritSec);
// Connect to DB
EnterCriticalSection(&gCriticalSection);
GetModuleFileName(NULL,szProcessName,255);
OutputDebugString(szProcessName);

CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);

if (pConn==NULL)
{
pConn.CreateInstance(__uuidof(Connection));
try
{
pConn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=DB.mdb;Mode=ReadWrite;Persist Security Info=False;","","",adModeUnknown);
OutputDebugString("Connected DB ... \n");
}
catch(_com_error e)
{
OutputDebugString("Connect DB error. \n");
}
}
LeaveCriticalSection(&gCriticalSection);
TlsIndex = TlsAlloc();
break;

case DLL_THREAD_ATTACH:
break;

case DLL_THREAD_DETACH:
break;

case DLL_PROCESS_DETACH:
bDetached = TRUE;

EnterCriticalSection(&gCriticalSection);
if (pConn)
{
pConn->Close();
pConn=NULL;
}
CoUninitialize();

if (gBaseInfo)
{
int Error;

FreeSocketsAndMemory(&Error);
}
LeaveCriticalSection(&gCriticalSection);

DeleteCriticalSection(&gCriticalSection);
DeleteCriticalSection(&gOverlappedCS);
DeleteCriticalSection(&gDebugCritSec);

if (lpvReserved == NULL)
{
if (TlsIndex != 0xFFFFFFFF)
{
TlsFree(TlsIndex);
TlsIndex = 0xFFFFFFFF;
}
}
break;
}

return TRUE;
}

when it run to the line pConn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=DB.mdb;Mode=ReadWrite;Persist Security Info=False;","","",adModeUnknown); in

VC debug environment, it stoped and never execute the next line.

How to resolve it ? I'm a beginner in the field and thank you very much.

Best Regards
[2921 byte] By [yukuang] at [2007-11-20 0:52:41]
# 1 Re: Pls help me. I want to use ADO to read records from MS Access 2003 in a DLL.
ADO? THis is the ADO.net forum. If you wan this topic moving to another place, let me know and I will do it..
cjard at 2007-11-10 3:30:13 >