CDatabase under VC 6.0 no longer opens. 
Author Message
 CDatabase under VC 6.0 no longer opens.

I am using VC 6.0 to recompile and distribute an ISAPI DLL which opens a
single connection to a database.  Now that I have converted the project to
VC 6.0, the CDatabase::OpenEx or the CDatabase::Open calls will no longer
work.  I have traced the calls has far as I can go and it seems to hang in
the DBCore.cpp.  This is the connect function:

BOOL CDatabase::Connect(DWORD dwOptions)

 HWND hWndTop;
 HWND hWnd = CWnd::GetSafeOwner_(NULL, &hWndTop);
 if (hWnd == NULL)
  hWnd = ::GetDesktopWindow();

 UCHAR szConnectOutput[MAX_CONNECT_LEN];
 RETCODE nRetCode;
 SWORD nResult;
 if (dwOptions & noOdbcDialog)
  wConnectOption = SQL_DRIVER_NOPROMPT;
 else if (dwOptions & forceOdbcDialog)
  wConnectOption = SQL_DRIVER_PROMPT;
-> AFX_SQL_SYNC(::SQLDriverConnect(m_hdbc, hWnd,
->  (UCHAR*)T2A((LPTSTR)(LPCTSTR)m_strConnect), SQL_NTS,
->  szConnectOutput, _countof(szConnectOutput),
->  &nResult, wConnectOption));
 if (hWndTop != NULL)
  ::EnableWindow(hWndTop, TRUE);

 // If user hit 'Cancel'
 if (nRetCode == SQL_NO_DATA_FOUND)
  return FALSE;

 if (!Check(nRetCode))
#ifdef _DEBUG
  if (hWnd == NULL)
   TRACE0("Error: No default window (AfxGetApp()->m_pMainWnd) for

 // Connect strings must have "ODBC;"
 m_strConnect = _afxODBCTrail;
 // Save connect string returned from ODBC
 m_strConnect += (char*)szConnectOutput;

 return TRUE;


The arrows indicate where the app fails.  It seems to call this function and
never return.  No error, just never returns.
I have tried creating a new CDatabase object and opening a completely
different datasource, but the same thing happens.

If anyone has any ideas as to what is happening here, I would greatly
appreciate your input.


Nicholas Twerdochlib
Nikom Network Services

Sun, 11 Feb 2001 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. CDatabase under VC 6.0 no longer opens.

2. CDatabase opens as read only in

3. vc++ 6.0 crashes when opening a file

4. HELP!!! Opening Serial Ports through VC 6.0

5. Display of File Open Dialog Box in Win32 App in VC 6.0

6. long long support VC/VC++ .NET?

7. Long (too long) link time in VC++6.0

8. char size (was long long long long long int)

9. Long (too long) link time in VC++6.0

10. long long long long integers

11. Problem to convert from VC 6.0 to VC 7.1 because of using filebuf::setmode()

12. upgrade of dll from vc++ 6.0 to


Powered by phpBB® Forum Software