CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    Microsoft Access OLE Automation Connection

    Hi all,
    I'm trying to connect, via OLE Automation, my application to a lock by password an Access data base using ADO. The connection only works if I disable the password in the database itself, then run my application. This situation is not suitable since I do not want the users to be able to enter the database through Access but through my application only. Does anyone now how to be able through a file DSN and OLE Automation to open a lock Access Database? Or does anyone have a simpler solution?

    Regards,


  2. #2
    Guest

    Re: Microsoft Access OLE Automation Connection


    Q161016 - ACC: How to Use DAO to Open Password-Protected Database (95/97)
    http://support.microsoft.com/support.../q161/0/16.asp

    The following code will do the trick for Acc 2000:

    Option Compare Database
    Option Explicit

    Sub OpenPasswordProtectedDB()

    'Define as Static so the instance of Access
    'doesn't close when the procedure ends.
    Static acc As Access.Application
    Dim db As DAO.Database
    Dim strDbName As String
    strDbName = "c:\My Documents\test.mdb"
    Set acc = New Access.Application
    acc.Visible = True
    Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=cool") 'cool is the password
    acc.OpenCurrentDatabase strDbName
    db.Close
    Set db = Nothing
    End Sub



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

Featured