Solved

Protected database and datacontrol

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

791 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