using Recordset update method

using Recordset update method

Post by junge » Fri, 18 Jul 2003 05:34:55

I'm trying to update a row by modifying the fields directly, but i can not
update if because
the RecordSet is ReadOnly after returns from Open(... and the cursor is
reseted to adOpenStatic..

I'm able to read and insert into Database but update fails.. ..why????
Whats wrong here???

  CString pcszSource(L"select * from MBDRstmt where TransID=10");
  VARIANT varTSQL;  VariantInit(&varTSQL);

  m_conn.spCON->put_Mode(adModeReadWrite); // adModeReadWrite=3

  _RecordsetPtr   spRS;

  spRS->LockType = adLockOptimistic;
  spRS->CursorType = adOpenKeyset;

  HRESULT hr = spRS->Open( varTSQL
   , adOpenKeyset
   , adLockOptimistic
   , adCmdText);
    if(FAILED(hr))  return; // it never fails here.
  ConnectModeEnum mode;
  m_conn.spCON->get_Mode(&mode); // returns mode=15 instead 3
  CursorTypeEnum cursor;
  spRS->get_CursorType(&cursor);// here cursor is already reseted to
  bool sopportUpdate = spRS->Supports(adUpdate); // returns false


1. Recordset Update Method

I'm having some problems with a simple database application. First, here's my

OS       = Windows 3.1
Compiler = VC++ 1.5b
Database = Access 2.0

My application is very simple and is based largely from the database tutorial
in the "Microsoft Foundation Class Library" manual. Instead of keeping track
of classes I'm keeping track of people and addresses. In the tutorial when a
user chooses Record|Add they must enter their data and move off of the record
in order to commit the changes. If they choose Record|Add, enter their data
and immediately choose File|Exit the new record in never saved. I would like
for the current record to be saved whenever the user closes the application. I
created a message handler for the WM_DESTROY message in the FormView class. It
looks a little something like this:

void CAddressBookView::OnDestroy()
                CATCH(CDBException, e)

However, the application still behaves as before. I chose Record|Add, enter
the data for a new record and choose File|Exit without moving off of the newly
created record. The new record is still not being saved.

I suppose I could always just call OnMove in the OnDestroy method but that
doesn't seem quite "proper". Any insights would be much appreciated.

Mike Luton

2. Cannot boot with new HD and fresh XP install

3. SQL Server CE: Recordset AddNew method does not work

4. Ms-Dos

5. ADOCE recordset find method

6. Q: VC-Fortran mixed program build within Dev Studio?

7. Can′t use the FIND method in recordset

8. ECC support ???

9. The value method of a recordset in ADOCE

10. Recordset and connection execute method with SSCE

11. using ADOCE recordset object in emulator

12. append recordsets to a db using ActiveSync

13. DAO: using the results of one recordset query in another??