Results 1 to 9 of 9

Thread: [RESOLVED] Recordset not updating

  1. #1

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Resolved [RESOLVED] Recordset not updating

    I have a routine that populates a dataset (SQL SERVER 2000). Then, it goes back to delete duplicates.

    The code that populates the database runs fine. The code that looks for sduplicates give me a [3251] Current record Does Not Support Updatign message. As mentioned, it does support updating, as the previous routines was able to add records.

    So here if the code up the line where the rrror occurs (at the rs1.update command):

    Code:
    '===========================
    Set rs1 = New ADODB.Recordset
    '===========================
    sql = "SELECT * FROM TMPCOMPNEEDED ORDER BY [UNPRTD],[LINE],[LOT],[ONHAND]"
    rs1.Open sql, CnxnTempSQL, adOpenKeyset, adLockOptimistic, adCmdText
    If Not rs1.BOF And Not rs1.EOF Then
        Do
            If UNPRTD = "" Then
                UNPRTD = rs1![UNPRTD]
                LINE = rs1![LINE]
                JOB = rs1![JOB]
                REMBAL = rs1![REMBAL]
                ONHAND = rs1![ONHAND]
                LOT = rs1![LOT]
            Else
                If Trim(rs1![UNPRTD]) = Trim(UNPRTD) And rs1![LINE] = LINE And rs1![LOT] = LOT And rs1![ONHAND] = ONHAND Then
                    rs1![DROPTHIS] = "X"
                    rs1.Update
                Else
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  2. #2
    Lively Member
    Join Date
    Dec 2005
    Posts
    113

    Re: Recordset not updating

    I've never used ADODB for SQL but in all my applications to update an MS Access database it would require the following:

    vb Code:
    1. rs1.Edit
    2. rs1![DROPTHIS] = "X"
    3. rs1.Update

    I'm probably gonna be wrong lol, but that's my input.

  3. #3

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Recordset not updating

    It doesn't like that bit of code.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Recordset not updating

    Try like this:
    code Code:
    1. '===========================
    2. Set rs1 = New ADODB.Recordset
    3. '===========================
    4. sql = "SELECT * FROM TMPCOMPNEEDED ORDER BY [UNPRTD],[LINE],[LOT],[ONHAND]"
    5. rs1.Open sql, CnxnTempSQL, adOpenKeyset, adLockOptimistic, adCmdText
    6. If Not rs1.BOF And Not rs1.EOF Then
    7.     rs1.EDIT
    8.     Do
    9.         If UNPRTD = "" Then
    10.             UNPRTD = rs1![UNPRTD]
    11.             LINE = rs1![LINE]
    12.             JOB = rs1![JOB]
    13.             REMBAL = rs1![REMBAL]
    14.             ONHAND = rs1![ONHAND]
    15.             LOT = rs1![LOT]
    16.         Else
    17.             If Trim(rs1![UNPRTD]) = Trim(UNPRTD) And rs1![LINE] = LINE And rs1![LOT] = LOT And rs1![ONHAND] = ONHAND Then
    18.                 rs1![DROPTHIS] = "X"
    19.                 rs1.Update
    20.             Else
    21.  
    22. Missing stuff here
    23.     rs1.MoveNext
    24. WEnd
    25. rs1.Update
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  5. #5

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Recordset not updating

    It does like .edit at all, nowhere.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  6. #6

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Recordset not updating

    When I get rid of this "ORDER BY [UNPRTD],[LINE],[LOT],[ONHAND]", I do not get the error message. Making headway.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  7. #7
    Lively Member
    Join Date
    Dec 2005
    Posts
    113

    Re: Recordset not updating

    Must be because it's SQL, actually I don't use .edit and .update to remove a record from MS Access databases, I've always just used .delete. Must be totally different when accessing SQL.

  8. #8

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Recordset not updating

    I created an index on the recordset and it worked. Go figure.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  9. #9
    Lively Member
    Join Date
    Dec 2005
    Posts
    113

    Re: [RESOLVED] Recordset not updating

    Lol at least it's working, sorry I couldn't help.

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