Solved

Protected database and datacontrol

Posted on 1997-05-01
4
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 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