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,

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)

HI!

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
{
BEGIN_ADO_BINDING(CCustomRs)
     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)
END_ADO_BINDING()
public:
    long    m_id;
    CHAR    m_text[50];

    ULONG   m_ul_idStatus;
    ULONG   m_ul_textStatus;

void main(void)
{
 ::CoInitialize(NULL);
   try
      {
    _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);

      TESTHR(picRs->BindToRecordset(&rs));

   strcpy (rs.m_ch_lname, "qwe");
   picRs->AddNew(&rs);

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

         pRs->MoveNext();
         }
      }
   catch (_com_error &e )
      {
      printf("Error:\n");
      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());
      }
   ::CoUninitialize();
I try this code with MDAC 2.5, 2.6. Maybe i made a mistake. But where is it?
So pls help

Roni

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