Results 1 to 9 of 9

Thread: [RESOLVED] [Access] DB Corruptions

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    15

    Resolved [RESOLVED] [Access] DB Corruptions

    Quote Originally Posted by RobDog888

    I guess the next q would be why does your db get corrupted so often?
    We have a lot of customers. It does not happen to any one database often, but we do see it about once a month over the whole customer base.

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

    Re: [MS Access] - Hide Database Objects

    Usually corruptions occur in Access from improperly closing connections, not closing of connection(s) and multiple db technologies connected to the same db.
    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
    New Member
    Join Date
    May 2006
    Posts
    15

    Re: [MS Access] - Hide Database Objects

    Okay, here's another idea (and maybe this should be a different thread). I've been reading about persistent data. If I create a recordset of the one table I want to hide and then save it as a text file using:

    oRs.Save "C:\Test.txt", adPersistADTG

    (as you suggested in http://www.vbforums.com/showthread.p...t=export+table) and do this each time someone successfully opens the database, then I'd have a fairly current backup of the table.

    My problem is I don't know how to import this back to restore the table. I think I can use oRs.Open to get the data into a recordset, but then what do I do? Do I loop through the recordset and Insert records into a restored empty table?

    Thanks,

    John

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

    Re: [MS Access] - Hide Database Objects

    I'll split these posts to a new thread in the Office forum.

    Yes, reading the saved table back in but may be best to use an INSERT INTO sql action statement to load the table.
    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

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    15

    Re: [Access] DB Corruptions

    So, I am assuming JetComp will remove the hidden table in its entirety. Therefore, we'd replace it with an empty table and then loop through the opened recordset with INSERT INTO statements to restore all the data. Is that correct? In other words, the saved data does not save the table structure, right?

    I presume using adPersistXML would be the same?

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    15

    Re: [Access] DB Corruptions

    After doing a lot of investigating, it seems that loading a recordset into an empty table is a non-trivial task. I could find no good examples of it anywhere.

    It seems the INSERT usage (either INSERT INTO or INSERT SELECT) will require naming every field. I'd like to avoid that. Then I thought about opening a second recordset from the empty table and loop through the first recordset using ADDNEW for the table recordset, but I don't know what syntax to use to assign the values. Would I need to loop through all the fields on each record?

    Any help is greatly appreciated.

    John

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    15

    Re: [RESOLVED] [Access] DB Corruptions

    Okay, it's amazing what a good night's sleep and a big cup of coffee in the morning can do to help you figure things out. The code that works is more trivial than I thought it would be. This works:

    Code:
    With rsOne
         .Open App.Path & "\test.txt", "PROVIDER=MSPersist;", , , adCmdFile
         .MoveFirst
          rsTwo.Open "select * from tblTest", Conn, adOpenStatic, adLockOptimistic
       Do While .EOF = False
           rsTwo.AddNew
           For i = 0 To .Fields.Count - 1
                rsTwo.Fields(i).Value = .Fields(i).Value
           Next i
           rsTwo.Update
           .MoveNext
        Loop
       rsTwo.Close
       .Close
    End With
    John
    Last edited by JohnHamcoex; Jul 5th, 2008 at 09:47 AM. Reason: Code tags

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

    Re: [RESOLVED] [Access] DB Corruptions

    I'm back John (was celebrating the 4th).

    That will work but if you have alot of records it may be a performance issue.
    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

  9. #9

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    15

    Re: [RESOLVED] [Access] DB Corruptions

    Quote Originally Posted by RobDog888
    I'm back John (was celebrating the 4th).

    That will work but if you have alot of records it may be a performance issue.
    True. But hopefully it is a rare occurance, maybe once a month.

    In any event, I think this is a pretty cool workaround for hiding db tables (as you described) for security, and having the table data backup in case a Compact and Repair deletes the table.

    Works for me.

    Thanks for all of your suggestions and help. You're a great resource.

    John

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