CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Location
    Brooklyn, NY USA
    Posts
    171

    LastModified in ADO

    I need to have OrderID (Autonumber) of new record to create related record in a OrderDetail table. With DAO or Data Control it's very simple:
    Data1.UpdateRecord
    Data1.Recordset.Bookmark = Data1.Recordset.LastModified
    Now you can reference to Data1.Recordset.Fields("OrderID") to get new OrderID.
    How to perform this simple task with ADO DataControl or recordset?
    To see the problem place regular DC and regular DBGrid, ADO DC and ADO Grid on the form. Connect both Data Controls to the same Table with Autonumber field and Grids to Data Controls respectively. Set AllowAddNew properties to True
    and try to add new records in both grids. In regular Grid you'll see ID of new record just after you swiched to the previous record or performed
    Data1.UpdateRecord
    Data1.Recordset.Bookmark = Data1.Recordset.LastModified.
    With ADO Grid you see "0" after you leave new record and if you come back to check the value of ID of new record, you'll find there Null.
    I coudn't find anything similar to LastModified with ADO. I can only do
    Adodc1.Recordset.Update
    Adodc1.Refresh
    Adodc1.Recordset.MoveLast
    Sorry for long explanation.
    Any help would be appreciated.
    Thank you.
    Vlad



  2. #2
    Join Date
    Apr 1999
    Location
    Brooklyn, NY USA
    Posts
    171

    Re: LastModified in ADO

    I've got fixed my problem.
    First of all I used "PROVIDER=Microsoft.Jet.OLEDB.4.0" and .CursorLocation = adUseClient. When I changed it to "PROVIDER=Microsoft.Jet.OLEDB.3.51" and .CursorLocation = adUseServer it started to work the same way as with DAO.
    I did it because I don't know the difference between them and I desided to use latest version. And if let's say I didn't have anything in a grid I would change Provider, but I did have.

    Vlad


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