?
Solved

Protected database and datacontrol

Posted on 1997-05-01
4
Medium Priority
?
241 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 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
Suggested Courses

770 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