Solved

Protected database and datacontrol

Posted on 1997-05-01
4
219 Views
Last Modified: 2012-08-13
Problem with datacontrol and protected database using VB4-16 bit and DAO
I can't access the secured database with the datacontrol
Database LANG.MDB is open for all
Database SUPP.MDB is protected, ADMIN have no rights and John have all rights
This example have one form with a datacontrol called dbSupplier

Private Sub Form_Load()
  Dim wslanguage As Workspace
  Dim wsdata As Workspace
  Dim dbl As Database
  Dim dbs As Database
  Dim tlanguage As Recordset
  Dim rsSupplier As Recordset

  DBEngine.IniPath = App.Path & "\" & "MYSYDB.INI"
  Set wslanguage = DBEngine.CreateWorkspace("wslanguage", "Admin", "")
  Set dbl = wslanguage.OpenDatabase("LANG.MDB")
  Set tlanguage = dbl.OpenRecordset("Language", dbOpenTable)
  tlanguage.Index = "Primarykey"

  Set wsdata = DBEngine.CreateWorkspace("wsData", "John", "secret")
  Set dbs = wsdata.OpenDatabase("SUPP.MDB")
  Set rsSupplier = dbs.OpenRecordset("Supplier", dbOpenDynaset)
 
  rsSupplier.MoveFirst
  Do While Not rsSupplier.EOF           ' This works fine
    Debug.Print rsSupplier("Name")
    rsSupplier.MoveNext
  Loop
 
  Set dbSupplier.Recordset = rsSupplier
  dbSupplier.Refresh                    ' No permission !
 
  ' It seems like the datacontrol still uses the rights form the default
  ' workspace - Workspace(0)
End Sub
0
Comment
Question by:Erling Brodersen
  • 2
  • 2
4 Comments
 

Expert Comment

by:mikekr
ID: 1425887
I thing the problem might be with the line:-

Set dbSupplier.Recordset = rsSupplier

Try this instead :-

Set dbSupplier.Recordset = dbs.OpenRecordset("Supplier", dbOpenDynaset)
0
 
LVL 4

Expert Comment

by:Chizl
ID: 1425888
What version of VB are you using?  

0
 

Expert Comment

by:mikekr
ID: 1425889
Ver 4.0 Pro
0
 
LVL 4

Accepted Solution

by:
Chizl earned 100 total points
ID: 1425890
This is straight from the book!  Hope it helps..

------------------
This example creates a new Microsoft Jet Workspace object and a new ODBCDirect Workspace object and appends them to the Workspaces collection. It then enumerates the Workspaces collections and the Properties collection of each Workspace object. See the methods and properties of the Workspace object or Workspaces collection for additional examples.

Sub WorkspaceX()

      Dim wrkNewJet As Workspace
      Dim wrkNewODBC As Workspace
      Dim wrkLoop As Workspace
      Dim prpLoop As Property

      ' Create a new Microsoft Jet workspace.
      Set wrkNewJet = CreateWorkspace("NewJetWorkspace", "admin", "",dbUseJet)
      Workspaces.Append wrkNewJet

      ' Create a new ODBCDirect workspace.
      Set wrkNewODBC = CreateWorkspace("NewODBCWorkspace", "admin", "", dbUseODBC)
      Workspaces.Append wrkNewODBC

' Enumerate the Workspaces collection.
      For Each wrkLoop In Workspaces
            With wrkLoop
                  Debug.Print "Properties of " & .Name
                  ' Enumerate the Properties collection of the new
                  ' Workspace object.
                  For Each prpLoop In .Properties
                        On Error Resume Next
                        If prpLoop <> "" Then Debug.Print "    " &       prpLoop.Name & " = " & prpLoop
                        On Error GoTo 0
                  Next prpLoop
            End With
      Next wrkLoop

      wrkNewJet.Close

wrkNewODBC.Close

End Sub
------------------
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

708 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