Solved

Protected database and datacontrol

Posted on 1997-05-01
4
222 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

919 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

22 Experts available now in Live!

Get 1:1 Help Now