BUG in SQLOLE, VC Debugger or _My_Code ?!?!?!?

BUG in SQLOLE, VC Debugger or _My_Code ?!?!?!?

Post by Anna Rynda » Tue, 23 Dec 1997 04:00:00

Hi All
I have built a simple ATL object (as local server) to automate exporting
a table
contents to a file. I make use of SQLOLE Distributed Management Objects
library from MS SQLServer 6.5 to do the job. When I let the local server
without attaching  to the de*, it succeeds everytime!!!
Unfortunatelly when I debug my program, method ExportData of
object fails. It fails near the end of bulking out the table.It seems
that the all data
is already written in the data file. Both debug and not debug files have
467,536 bytes.
There is no status written to the log file while debugging (although is
created has
length 0 bytes).

This is a fragment of OUTPUT window (in debug):
Loaded 'C:\WINNT\system32\netrap.dll', no matching symbolic information
Loaded 'C:\WINNT\system32\SAMLIB.DLL', no matching symbolic information
Loaded 'C:\WINNT\system32\dbnmpntw.dll', no matching symbolic
information found.
A>>> First-chance exception in bcptest.exe (NTDLL.DLL): 0xC0000008: (no
First-chance exception in bcptest.exe (KERNEL32.DLL): 0xE06D7363:
Microsoft C++ Exception.
First-chance exception in bcptest.exe (KERNEL32.DLL): 0xE06D7363:
Microsoft C++ Exception.
B>>> Linked object's source class has changed
  >>> - Code execution exception:  8

A) is an exception (I think caused by SQLOLE.dll)
    Winnt.h header file says: STATUS_INVALID_HANDLE            ((DWORD
B) is a trace (description extracted from _com_error object)
       of the exception from SQLOLE::ExportData

None of above exception occur when I am not debugging!!!
Is this SQLOLE or VC++ De* BUG? Or I have made a mistake?!?! If so

I figured that SQLOLE might want to write to the log file but the
de* has
invalidated the log file handle and it fails with STATUS_INVALID_HANDLE
exception. But is it true?!?!?

Please help me!! I can hardly develop my program any further!!!

This is code of the method to does all the work. It is being called from
VB client.
The most important lines are at the end of the method code:

STDMETHODIMP Cbcp::export(BSTR server, BSTR login, BSTR passwd, BSTR
database, BSTR table, BSTR folder)
 // convert parameters
 _variant_t vSrv,vLogin,vPasswd;
 _bstr_t bsDB,bsTab,bsFolder;
 vSrv = server;vLogin= login;vPasswd = passwd;
 bsDB = database;bsTab = table;
bsFolder = folder; // destination folder for 3 files : data
// errors (ERR_tablename.dat) and LOG (LOG_tablename.dat)
 HRESULT hres;
 try {
  SQLOLE::_SQLServerPtr spSQLServer;
  SQLOLE::_DatabasePtr spDatabase;
  SQLOLE::_TablePtr spSQLTable;   // spointer to SQLOLE Table

  // create and connect to server

  // find specified database
  _variant_t cDb,iDb;
  cDb.vt = iDb.vt = VT_I4;
  cDb = spSQLServer->Databases->Count;
  iDb = 1L;

  while (iDb.lVal<=cDb.lVal) {
   spDatabase = spSQLServer->Databases->Item(iDb);
   _bstr_t name = spDatabase->Name;
   if (name== bsDB)
  if (iDb.lVal>cDb.lVal)

  // find specified table
  _variant_t cTbl,iTbl;
  cTbl.vt = iTbl.vt = VT_I4;

  cTbl = spDatabase->Tables->Count;
  iTbl = 1L;

  while (iTbl.lVal<=cTbl.lVal) {
   spSQLTable = spDatabase->Tables->Item(iTbl);
   if (spSQLTable->Name == _bstr_t(bsTab))
  if (iTbl.lVal>cTbl.lVal)

  // prepare file paths
  _bstr_t bsBCPfn,bsLOGfn,bsERRfn;
  bsBCPfn = bsFolder + "\\BCP_" + spSQLTable->Name + ".dat";
  bsLOGfn = bsFolder + "\\LOG_" + spSQLTable->Name + ".dat";
  bsERRfn = bsFolder + "\\ERR_" + spSQLTable->Name + ".dat";

  // delete above files if already exist
  if (remove(bsBCPfn)==-1)
   if (errno!=ENOENT) {
    ATLTRACE("CSyncTable::ExportData could not remove data file:
  if (remove(bsLOGfn)==-1)
   if (errno!=ENOENT) {
    ATLTRACE("CSyncTable::ExportData could not remove log
  if (remove(bsERRfn)==-1)
   if (errno!=ENOENT) {
    ATLTRACE("CSyncTable::ExportData could not remove err

  // create and initialize SQLOLE::BulkCopy object
  SQLOLE::_BulkCopyPtr spBCP;
  if FAILED(hres=spBCP.CreateInstance(__uuidof(SQLOLE::BulkCopy)))

  spBCP->DataFilePath = bsBCPfn;
  spBCP->ErrorFilePath = bsERRfn;
  spBCP->LogFilePath = bsLOGfn;

  // finally do the job!    // AFTERHERE EXCEPTIONS ARE THROWN
  long lres = spSQLTable->ExportData((SQLOLE::_BulkCopy*)spBCP);
  ATLTRACE("BCP returned (num of rows copied) : %ld\n",lres);
 catch (_com_error &err) {    // HERE I CATCH THEM AND DISPLAY
  ATLTRACE(_T("%s - %s"),err.ErrorMessage(),(LPSTR)err.Description());
  return E_FAIL;
 return S_OK;



BUG in SQLOLE, VC Debugger or _My_Code ?!?!?!?

Post by Kuba Szmigielsk » Wed, 24 Dec 1997 04:00:00

I have also made an inprocess server and the problem persists. :-(((

Please, do help!!!

I'm sorry I posted the previous message from someone else computer.
Please send any information to:


BUG in SQLOLE, VC Debugger or _My_Code ?!?!?!?

Post by Kuba Szmigielsk » Wed, 24 Dec 1997 04:00:00

It is probably a strange configuration problem on my machine.
It didn't appear on any of two other machines in my domain.
I'll try to reinstall some stuff.

Thanx anyway.


1. BUG in SQLOLE, VC Debugger or _my_code ?!?!?!?

There are known bugs in the ImportData method.  It's easy to imagine there are
similar problems with ExportData.  Among other things, ImportData has a memory
allocation bug that gives intermittent Access Violations.  You find that your
problem is not simply configuration, but that the bug is dependent on various
timing issues.

Scott Nichol
e-mail: Remove nospam. from reply address

2. Recovery for dinosaur

3. Looking for large test data

4. Difference between OLE DB 8.0 and OLE DB

5. VC-DEBUGGER can't install

6. VC++6.0 Database BUG?

7. VC++6.0 Bug correction...please confirm.

8. A very big bug found in VC 6.0

9. GOT VC 5.0 BUGS???