CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Location
    Argentina....
    Posts
    118

    _RecordsetPtr::AddNew()

    Hi,
    i'm connecting to an access database useing _RecordsetPtr::Open(...), after that, I verify that i can put data on it, useing_RecordsetPtr::Supports(adAddNew) and _RecordsetPtr::Supports(adUpdate), but when i call to the _RecordsetPtr::AddNew() function, it adds a row in the top of the table, but all with black record, and i can't modify it.... anyone knows why it happens???

    Thanks in advance,
    Diego
    My history: QB->VB->TC++->VB->VC++->VC#

  2. #2
    Join Date
    May 2003
    Posts
    19
    Any call to the ::AddNew() method will ADD a row to your database. Call AddNew() and then set the database fields with data and lastly call your ::Update() method to write the data to the new record.

    The addnew() method should actually be the 2nd LAST call you make to a database, followed by a call to ->Update(), followed by a ->close() call.

    I do this ALL the time and the way I do this stuff is to Addnew(), Set the database fields and then call update.
    //
    //Our table has three fields
    //
    rsAgenda->AddNew();
    rsAgenda->Fields->GetItem("FName")->Value=vt_FirstName;
    rsAgenda->Fields->GetItem("LName")->Value=vt_LastName;
    rsAgenda->Fields->GetItem("PCode")->Value=vt_Postcode;
    rsAgenda->Update();
    //Database update complete. Call ->Close() is necessary.

    ++Roddy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured