Results 1 to 8 of 8

Thread: [RESOLVED] VB6 - Row cannot be located for updating

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Resolved [RESOLVED] VB6 - Row cannot be located for updating

    I am using a bound DataGrid Control and ADO to read email messages. When a new message is read, a boolean field is updated to show that it has been read. To get around delay issues with updating the database and the error:
    "Row cannot be located for updating. Some values may have been changed since it was last read.",
    I use the following code to force the database to be updated.
    Code:
        'Update database as message read
        If lblBox.Caption = "InBox" Then
            DataGrid1.Col = 3
            If DataGrid1.Text = False Then
                DataGrid1.Text = True
                DataGrid1.Col = 0
                'Trigger update
                Adodc1.Recordset.MovePrevious
                Adodc1.Recordset.MoveNext
            End If
        End If
    This works for the most part, but if I go off and perform some other functions before coming back to read a new message, I still get the above error. Unfortunately I have not been able to isolate what those "other functions" are, as it happens quite rarely. The operation still succeeds, but it crashes the program because I do not trap this particular error.

    Any ideas?

    J.A. Coutts

  2. #2
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: VB6 - Row cannot be located for updating

    *What database are you connecting to
    *whats the cursor type
    *did you query the whole table including the PK.
    *are you using transactions
    *are you using .Find



    ALSO check this... https://web.archive.org/web/20130417....com/kb/300586


    The workaround is to run the update as a separate ADO command, and then refresh the ADODC. (don't update the ADODC recordset directly)

    this is why people tend to stay away from the ADODC
    it's quick to setup a half functioning gui - but then you waste time trying to work around it.
    Last edited by DEXWERX; Oct 3rd, 2017 at 04:35 PM.

  3. #3
    New Member
    Join Date
    Oct 2017
    Posts
    1

    Re: VB6 - Row cannot be located for updating

    hi,my friend this is wonderful job.
    wish you good luck.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Re: VB6 - Row cannot be located for updating

    *What database are you connecting to
    - Access 2000 using ODBC
    *whats the cursor type
    - adOpenDynamic
    - database was added to in a totally separate program.
    *did you query the whole table including the PK.
    - This program uses a SELECT query to populate the bound control with relevant data only. When the user clicks on a line, the Primary Index (Auto Number) is used in another SELECT query to recover the data used to populate the message window. The only database change that is made here is a Yes/No (Boolean) field used to indicate if the message has been viewed.
    *are you using transactions
    - No.
    *are you using .Find
    - No.

    The full source code is available in any of the posted Versions of JACMail. This has been a minor issue for some time.

    J.A Coutts

  5. #5
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: VB6 - Row cannot be located for updating

    if you check that KB article i linked, you can see that the ADODC doesn't like when you update its recordset directly (specifically with MS Access).
    They suggested a workaround which is to do the update with a separate command object, and then just Refresh the ADODC.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Re: VB6 - Row cannot be located for updating

    Quote Originally Posted by DEXWERX View Post
    if you check that KB article i linked, you can see that the ADODC doesn't like when you update its recordset directly (specifically with MS Access).
    They suggested a workaround which is to do the update with a separate command object, and then just Refresh the ADODC.
    The linked KB article may or may not relate to the issue I described earlier, but I have run into a new problem that seems to be more directly related. The database is updated with the .AddNew function. Because the next program requires the AutoNumber assigned to the record, that number is recovered using an SQL query. That part works just fine.

    The AutoNumber is passed to a separate program, which uses another SQL statement to recover the record just added to the database. The SQL query fails to recover the record. Because it failed to recover the record and it has not been sent to the far end yet, a timer activates the same process 10 minutes later and it goes through without a problem.

    It appears there is some kind of timing issue here. Any ideas?

    J.A. Coutts

  7. #7
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: VB6 - Row cannot be located for updating

    You're using a SQL query to get an ID number from a DB, and another program is querying the same DB with the passed ID number / and it can't find the record. That's completely odd. You could try reconnecting to the DB before running the sql in the second program, but that's my only suggestion.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Re: VB6 - Row cannot be located for updating

    Quote Originally Posted by DEXWERX View Post
    You're using a SQL query to get an ID number from a DB, and another program is querying the same DB with the passed ID number / and it can't find the record. That's completely odd. You could try reconnecting to the DB before running the sql in the second program, but that's my only suggestion.
    It turns out that the first program was using "msado15.dll" dated 04/21/2017, and the second program was using "msado60.tlb" dated 08/21/2013. I don't pretend to understand the difference, but when I changed the second program to use "msado15.dll", the problem went away.

    J.A. Coutts

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