Results 1 to 4 of 4

Thread: Add record receives error message (resolved)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2004
    Location
    Texas
    Posts
    144

    Add record receives error message (resolved)

    Hi,
    Can anyone tell me why I kept getting this error message. I am trying to add a record into the database "test.mdb" and a table "table1".

    ID | One | Two | Three | Four | Five | Six | Seven |
    --------------------------------------------------
    01 | 101 | 202 | 3003 | 404 | 505 | 66 | 71117 |
    02 | 111 | 212 | 3113 | 414 | 515 | 66 | 72227 |

    Thanks,

    Phillip

    "Run-time error '3251':"
    "Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype."


    Code:
    Private Sub Command6_Click()
    Dim con As Adodb.Connection
    Dim rs As Adodb.Recordset
    
    Set con = New Adodb.Connection
    con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & InputFileName & ";"
    
    con.Open
    Set rs = con.Execute("SELECT One, Two, Three, Four, Five, Six, Seven FROM Table1")
    
    With rs
     .AddNew
     .Fields("One") = Text1(13).Text
     .Fields("Two") = Text1(12).Text
     .Fields("Three") = Text1(11).Text
     .Fields("Four") = Text1(10).Text
     .Fields("Five") = Text1(9).Text
     .Fields("Six") = Text1(8).Text
     .Fields("Seven") = Text1(7).Text
     .Update
     .Close
    End With
    End Sub
    Last edited by Iat; Sep 6th, 2004 at 08:53 AM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Its because your not specifing the cursor and lock type, so it
    uses the default, which are adOpenFowardOnly and
    adLockReadOnly. Try changing your open statement to this.

    VB Code:
    1. Set rs = New ADODB.Recordset
    2. rs.Open "SELECT One, Two, Three, Four, Five, Six, Seven FROM Table1", con, adOpenKeyset, adLockOptimistic, adCmdText
    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2004
    Location
    Texas
    Posts
    144
    Thanks Robdog88. That fixed my problem.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    No prob.
    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