Results 1 to 7 of 7

Thread: [RESOLVED] Problem in ado code

  1. #1

    Thread Starter
    Addicted Member thamizhinpan's Avatar
    Join Date
    Dec 2005
    Location
    TE
    Posts
    243

    Resolved [RESOLVED] Problem in ado code

    I have creating a data management program with ado code.
    But when I use Addnew or delete command I can see this error
    Code:
    3251 - Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.
    What is the meaning of this error statement.
    How can I solve it?
    If above question or answer will help to you
    Don't forget to rate me
    தமிழ்இன்பன்

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Problem in ado code

    how are you opening your recordset?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Addicted Member thamizhinpan's Avatar
    Join Date
    Dec 2005
    Location
    TE
    Posts
    243

    Re: Problem in ado code

    Code:
    Dim mobjADOConn As ADODB.Connection
    Dim mobjADORst  As ADODB.Recordset
    Dim mstrSQL     As String
    
    'local variable(s) to hold property value(s)
    Private sWorkTable As String  'local copy
    
    
    
    private sub connect()
    Dim sConnectionString As String
    sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Source-Z.mdb;Persist Security Info=False"
       
        ' Connect to the Property database:
        Set mobjADOConn = New ADODB.Connection
        mobjADOConn.ConnectionString = sConnectionString
        mobjADOConn.Open
        
        Dim lngX As Long
        
        
        'select or reload the data to be displayed:
        mstrSQL = "select * from " & sWorkTable
        
        Call OpenNewRecordset
    End sub
    
    
    
    '-----------------------------------------------------------------------------
    Private Sub OpenNewRecordset()
    '-----------------------------------------------------------------------------
        Set mobjADORst = New ADODB.Recordset
        mobjADORst.CursorLocation = adUseClient
        mobjADORst.Open mstrSQL, mobjADOConn, adOpenStatic, , adCmdText
    
    End Sub
    If above question or answer will help to you
    Don't forget to rate me
    தமிழ்இன்பன்

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Problem in ado code

    Constant Description
    adOpenForwardOnly Forward-only cursor. Default. Identical to a static cursor except that you can only scroll forward through records. This improves performance in situations when you need to make only a single pass through a recordset.
    adOpenKeyset Keyset cursor. Like a dynamic cursor, except that you can't see records that other users add, although records that other users delete are inaccessible from your recordset. Data changes by other users are still visible.
    adOpenDynamic Dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the recordset are allowed, except for bookmarks if the provider doesn't support them.
    adOpenStatic Static cursor. A static copy of a set of records that you can use to find data or generate reports. Additions, changes, or deletions by other users are not visible.
    static is read only, use dynamic
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    Frenzied Member Campion's Avatar
    Join Date
    Jul 2007
    Location
    UT
    Posts
    1,098

    Re: Problem in ado code

    Also, you are not specifying a locktype. It defaults to adLockReadOnly.

    See this on lock types:
    http://msdn2.microsoft.com/en-us/library/ms680855.aspx

  6. #6
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Problem in ado code

    Try:
    Code:
    mstrSQL = "select * from " & sWorkTable
    Debug.Print mstrSQL
    Occam's Razor...

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Problem in ado code

    When you open a recordset without specifying any of the arguments it create a forward-only read-only recordset.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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