VC++ ADO Extensions - AddNew locks the table when in transaction

VC++ ADO Extensions - AddNew locks the table when in transaction

Post by Brett Gerhard » Tue, 30 May 2000 04:00:00


Hi, I'm using the ADO Extensions for VC++. When in a transaction, I "AddNew"
(using the IADORecordBindingPtr object, not the recordset object), for the
duration of the transaction all the tables that have data added to them are
locked for the whole time. Is this to be expected?.. I would have thought
some caching would be involved so that at least other queries could read
data in the table?

Many thanks for any help
 -=- Brett


1. AddNew method (ADO VC++ Extensions)


Does anybody can help me. I have a simple Access 97 database with a simple
table "Table" with fields "ID" (AutoNumber) and "Text" (Text). At the start
this table is empty. When i use ADO extensions (BEGIN_ADO_BINDING....
END_ADO_BINDING) and try to write new rows using method AddNew as a result a
have still empty database. Here the text:

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

#include <stdio.h>
#include <icrsint.h>

_COM_SMARTPTR_TYPEDEF(IADORecordBinding, __uuidof(IADORecordBinding));

inline void TESTHR(HRESULT _hr) { if FAILED(_hr) _com_issue_error(_hr); }

class CCustomRs : public CADORecordBinding
     ADO_FIXED_LENGTH_ENTRY(1, adInteger, m_id, m_ul_idStatus, false)
     ADO_VARIABLE_LENGTH_ENTRY2(2, adVarChar, m_text, sizeof(m_text),
m_ul_textStatus, true)
    long    m_id;
    CHAR    m_text[50];

    ULONG   m_ul_idStatus;
    ULONG   m_ul_textStatus;

void main(void)
    _RecordsetPtr pRs("ADODB.Recordset");
    CCustomRs rs;
    IADORecordBindingPtr picRs(pRs);

   pRs->Open("SELECT * FROM [Table]",
         "Provider=Microsoft.Jet.OLEDB.4.0;Data source=db.mdb",
         adOpenStatic, adLockOptimistic, adCmdText);


   strcpy (rs.m_ch_lname, "qwe");

   while (!pRs->EndOfFile)
         printf("Name = %s\n",
            (rs.m_ul_lnameStatus == adFldOK ? rs.m_ch_lname: "<Error>"));

   catch (_com_error &e )
      printf("Code = %08lx\n", e.Error());
      printf("Meaning = %s\n", e.ErrorMessage());
      printf("Source = %s\n", (LPCSTR) e.Source());
      printf("Description = %s\n", (LPCSTR) e.Description());
I try this code with MDAC 2.5, 2.6. Maybe i made a mistake. But where is it?
So pls help


2. sql*loader question

3. VC++ Extension for ADO and VC++ 5

4. JDBC / Oracle / DHCP

5. ADO Extensions-AddNew to an Empty Table Failed????

6. How to get PageCount on QReport?

7. VC++ Extensions and AddNew

8. vc ado extensions vs stored proc w output params

9. Writing datetime using VC++ ADO Extensions

10. ADO 2.0 VC++ Extensions