Access file

Posted on 2005-04-20
Last Modified: 2010-04-23

I'm writing a little windows application that uses data from an Access database.

Is there a way to change the access database file in a way you can't open it anymore with MSAccess ?

It should be only accessible within the application itself. But no one else should be able to get in there (exept me then :o) )

Question by:Jerry_0001
    LVL 96

    Expert Comment

    by:Bob Learned
    Not that I know of, but there is another place to ask Access questions:

    LVL 28

    Accepted Solution

    If you view an Access Database in notepad you will see "Standard Jet DB" in the header.
     Changing this information will cause the database to become unreadable via Access.

    'do not change it manually in word editor- db will be corrupted ( do it only through this proc)
    'but it can be done in hex editor

    Here is an example in VB6. It can be easily converted to VB.NET. I am just lazy to do it

    Private Sub Lock_Database(sPath As String, iAction As Integer)
    Dim iFreeFile   As Integer
    Dim lLoop       As Long
    Dim lLoc        As Long
    Dim sString     As String
        iFreeFile = FreeFile() 'Get free file #
        Open sPath For Binary As #iFreeFile 'Open specified file for binary I/O.

        lLoc = 1 'Set starting byte location
        Select Case iAction 'Set the header string for the appropriate action.
            Case 1
                 sString = "MYDB Database!!" 'Modified header data.
            Case 2
                 sString = "Standard Jet DB" 'Default header data.
        End Select
        For lLoop = 5 To 19 'loop through and update byte positions 9 through 15.
            Put #iFreeFile, lLoop, Mid$(sString, lLoop - 4, 1)
        Next lLoop

    Close #iFreeFile

    End Sub

    Author Comment

    I tried your solution.

    It locks and unlocks the database fine so you can't access it with MSAccess.

    But the problem is that when it's locked, you also can't access it through the .NET program...

    LVL 28

    Expert Comment

    Of course you cannot, But in .NET program you can unlockit first , do something and then lock it back

    Author Comment

    Stupid of me :o)

    That does the trick.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now