ADO and Transactions in VC++ 6.0 w/Access 97

ADO and Transactions in VC++ 6.0 w/Access 97

Post by Kevin Pumarl » Fri, 23 Apr 1999 04:00:00



So here's the deal -

I'm a novice at using ADO, (not to mention database usage in general) and
have spent much nashing of teeth looking for the elusive C++ examples that
exist under rocks here and there in amongst the VB  and HTML examples.  I've
managed to piece together enough information to get most of what I want to
do done, however, my attempts at using the transaction functions have as of
yet been unsuccessful.

I'm runnning NT 4.0 service pack 4.
Developing with VC++ 6.0.
I have Access 97 installed (my database needs at this point are small...).
And to the best of my knowledge I have installed the lastest and greatest
rendition of ADO - or so the web download page implied.

When I try and use 'BeginTrans' - an exception is thrown and I'm able to
extract the following error:

     "Description = [Microsoft][ODBC Microsoft Access 97 Driver]Operation
invalid at this time ".

I've decided that either I have the wrong drivers, and they don't support
the requested behavior - (but I believe them to be the most recent
drivers...?)  OR I'm somehow using the method incorrectly (see code snipit
below).

Has anyone experienced this?  What obvious thing am I not seeing?

Any comments would be greatly appreciated!

Thanx,
Kevin Pumarlo

P.S
I'm using the VC++ extensions for ADO - most handy given the alternative...

        CActionTableRs          rsActionTable;
        HRESULT                         hRes;
        IADORecordBinding*      pIrbRs1 = NULL;

        // Trap any error/exception
    try
    {
            //------------------------
            // Open Connection Object
            //------------------------

            // Create Connection Object - Conn1
            Conn1.CreateInstance( __uuidof( Connection ) );
            Conn1->ConnectionString = bstrAccessConnect;
            Conn1->Open( bstrEmpty, bstrEmpty, bstrEmpty, -1 );

            //-----------------------------------
            // Open Parameterized Command Object
            //-----------------------------------

            // Create Command Object
            Cmd1.CreateInstance( __uuidof( Command ) );
            Cmd1->ActiveConnection = Conn1;

            // Open Recordset Object  - Rs1
            Rs1.CreateInstance( __uuidof( Recordset ) );
            Rs1->Open(_bstr_t(bstrTable),
_variant_t(Conn1.GetInterfacePtr()), adOpenKeyset,
                                  adLockOptimistic, adCmdTable);

            Conn1->BeginTrans();

**** !!!!  At this point a '_com_error' exception is thrown yielding the
afore mentioned description.

 
 
 

ADO and Transactions in VC++ 6.0 w/Access 97

Post by Brian Kowal » Sat, 24 Apr 1999 04:00:00


I'm not sure if this applies to ADO, but when using ODBC via CDatabase and
CRecordSet, the BeginTrans fails if there are any open connections to the
record set. To get a transaction to work, I had to create a new connection.

Brian


Quote:> So here's the deal -

> I'm a novice at using ADO, (not to mention database usage in general) and
> have spent much nashing of teeth looking for the elusive C++ examples that
> exist under rocks here and there in amongst the VB  and HTML examples.
I've
> managed to piece together enough information to get most of what I want to
> do done, however, my attempts at using the transaction functions have as
of
> yet been unsuccessful.

> I'm runnning NT 4.0 service pack 4.
> Developing with VC++ 6.0.
> I have Access 97 installed (my database needs at this point are small...).
> And to the best of my knowledge I have installed the lastest and greatest
> rendition of ADO - or so the web download page implied.

> When I try and use 'BeginTrans' - an exception is thrown and I'm able to
> extract the following error:

>      "Description = [Microsoft][ODBC Microsoft Access 97 Driver]Operation
> invalid at this time ".

> I've decided that either I have the wrong drivers, and they don't support
> the requested behavior - (but I believe them to be the most recent
> drivers...?)  OR I'm somehow using the method incorrectly (see code snipit
> below).

> Has anyone experienced this?  What obvious thing am I not seeing?

> Any comments would be greatly appreciated!

> Thanx,
> Kevin Pumarlo

> P.S
> I'm using the VC++ extensions for ADO - most handy given the
alternative...

> CActionTableRs rsActionTable;
> HRESULT hRes;
> IADORecordBinding* pIrbRs1 = NULL;

> // Trap any error/exception
>     try
>     {
>             file://------------------------
>             // Open Connection Object
>             file://------------------------

>             // Create Connection Object - Conn1
>             Conn1.CreateInstance( __uuidof( Connection ) );
>             Conn1->ConnectionString = bstrAccessConnect;
>             Conn1->Open( bstrEmpty, bstrEmpty, bstrEmpty, -1 );

>             file://-----------------------------------
>             // Open Parameterized Command Object
>             file://-----------------------------------

>             // Create Command Object
>             Cmd1.CreateInstance( __uuidof( Command ) );
>             Cmd1->ActiveConnection = Conn1;

>             // Open Recordset Object  - Rs1
>             Rs1.CreateInstance( __uuidof( Recordset ) );
>             Rs1->Open(_bstr_t(bstrTable),
> _variant_t(Conn1.GetInterfacePtr()), adOpenKeyset,
>       adLockOptimistic, adCmdTable);

>             Conn1->BeginTrans();

> **** !!!!  At this point a '_com_error' exception is thrown yielding the
> afore mentioned description.


 
 
 

1. Using VC++ 6.0 as an automation client to view and print reports from MS Access 97

I have a VC++ application that reads and updates an MS Access Database. I am using DAO to interface with the Access database. The application is able to do all the database manipulations just fine. However, VC++ does not provide any built-in mechanism to print or view reports developed in MS Access.

I have tried to use the msacc8.olb type library to provide the capability to print and view reports. Unfortunately, there is little or no documentation on the classes and or how they should be used. Has anyone ever tried to do this? Is there a better way to accomplish what I am trying to do? Is there documentation available that discusses the access type library classes and how to use them from VC++?

Thanks
Mark

-----------------** -- Posted from CodeGuru -- **-----------------
http://www.codeguru.com/    The website for Visual C++ programmers.

2. IL-Chicago-47434--Programming Skills-ORACLE-EDI-OE candidates with Oracle and EDI.

3. Compact an Access Database in ADO using VC++ 6.0

4. passwords: getting to the master password

5. Access to access 2000 mdb by access 97 program via VB6 and ADO

6. Single User - how to ?

7. vc++, access, odbc and transactions

8. upgrade from Access to SQL

9. ACCESS 97 database required files for VC++ app??

10. VC++ 4.0 with Access '97

11. How to converting Access 97 to Sql 6.0?

12. Access 97 to SQL 6.0 : error -7777