Results 1 to 4 of 4

Thread: Problem With Refreshing Recordset

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    5

    Problem With Refreshing Recordset

    Why doesn't my recordset return the updated values? Everytime I add, update or delete a record and requery the recordset, it always returns the original values that does not reflect the new changes. How do I solve This? Please Help!

  2. #2

    Re: Problem With Refreshing Recordset

    Would .Refresh work?

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    5

    Re: Problem With Refreshing Recordset

    tried it but same result. I'm using vb6 and ms-access as the database

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    5

    Re: Problem With Refreshing Recordset

    Here's the code on how is connect and get the recordset
    VB Code:
    1. Option Explicit
    2.  
    3. Public conDB As New ADODB.Connection
    4. Public adoCom As New ADODB.Command
    5. -----------------------------------------------------------------------------------
    6. Public Function openConnectionDB(connection_string As String) As Boolean
    7.    
    8.     conDB.ConnectionString = connection_string
    9.     conDB.Mode = adModeUnknown
    10.     conDB.CursorLocation = adUseClient
    11.     conDB.ConnectionTimeout = 1
    12.    
    13.     On Error GoTo ConnectionFailed
    14.         conDB.Open
    15.         openConnectionDB = True
    16.         Exit Function
    17.        
    18. ConnectionFailed:
    19.     MsgBox Err.Description, vbCritical
    20.     openConnectionDB = False
    21.    
    22. End Function
    23. -----------------------------------------------------------------------------------
    24. Public Function getRecordset(SQLQuery As String) As ADODB.Recordset
    25.  
    26.   On Error GoTo GetRecordsetFailed
    27.  
    28.     Dim rs As New ADODB.Recordset
    29.    
    30.     If (rs.State = 1) Then
    31.         rs.Close
    32.     End If
    33.    
    34.     Set rs.ActiveConnection = Me.conDB
    35.     rs.CursorLocation = adUseClient
    36.     rs.CursorType = adOpenForwardOnly
    37.     rs.CacheSize = 50
    38.     rs.LockType = adLockOptimistic
    39.     rs.Source = SQLQuery
    40.     rs.Open
    41.    
    42.     Set getRecordset = rs
    43.        
    44.     Exit Function
    45.    
    46. GetRecordsetFailed:
    47.     Set getRecordset = Nothing
    48.     MsgBox Err.Description, vbCritical
    49.     Exit Function
    50.  
    51. End Function
    Last edited by si_the_geek; Apr 14th, 2006 at 12:42 PM. Reason: added VBCode tags

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