dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: how do u write to a specific row number in a DAO database

  1. #1
    Join Date
    Apr 1999
    Location
    Toronto, Canada
    Posts
    91

    how do u write to a specific row number in a DAO database

    Hello. This is a similar question that i had before. If i have the (index) row number in a database, how do i modify that specific row? I can't use .find or .seek - i have to go directly to that record (row) and modify the fields.

    Thanks
    TM

  2. #2
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167
    You don't usually work that way when dealing with RECORDSET. In order to UPDATE and DELETE a record, you'd point to it by the IDENTITY or if you're updating/deleting one or more records, you'd specify a criteria.

    Now, when you say a "record" (DAO/ADO), you basically mean that your RECORDSET object is currently pointing to a ROW in your table. How do you get it to point to a specific ROW? You can either achieve this by various ways via the RECORDSET object. You can use the .FINDxxxx() methods or the .FILTER properties.

    Once you're pointing to the row that you want to work with, you just have to specify what you want to do. For example, to delete the ROW, just use the .DELETE method. To update a certain field, you access it via the FIELDS collection. For example, to update the third field (lets say it is called FULLNAME), you can do it either by
    daoRS.Fields(2).Value = newValue
    or
    daoRS.Fields("FULLNAME").Value = newValue
    then you'd call .UPDATE() method to update those changes.

    Make sense?
    -Cool Bizs

  3. #3
    Join Date
    Apr 1999
    Location
    Toronto, Canada
    Posts
    91
    Thanks. It makes sense, but I wish there would be another way.
    Thanks again.

  4. #4
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090
    Use the AbsolutePosition property of the recordset object.

  5. #5
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080
    if you want to change a specific value of a column in many records in the table I recommend using SQL.. A lot faster..

    All you have to do is this

    youdb.Execute ("UPDATE table1 SET Table1.value = YourNewValue where (Condition) ");

    and here it is. Your table is modified.
    Nicolas Bohemier

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)