|
-
Jan 5th, 2001, 03:07 AM
#1
Thread Starter
Lively Member
How to create a workspace in vb 6?
Hi,
What is a workspace? Can anyone teach me how to create a workspace in vb 6?
The following is some codes that create workspace in vb 3. However when I load them in vb 6, it says
"Can't start your application. The workgroup information is missing or opened exclusively by another user."
Can somebody help me with this?
Thank you very much.
************************************************************
Private Sub cmdEnter_Click()
Dim myAccess As dynaset
Dim SQL As String
If txtID.Text = "" Then
MsgBox "Enter your ID"
txtID.SetFocus
Exit Sub
End If
If txtPassword.Text = "" Then
MsgBox "Enter your Password"
txtPassword.SetFocus
Exit Sub
End If
' to check id & password if correct??
On Error GoTo err_hand
SetDefaultWorkspace txtID.Text, txtPassword.Text
usr_id = txtID.Text
usr_password = txtPassword.Text
Dim loctext
loctext = LCase(App.Path)
If Right(App.Path, 1) <> "\" Then loctext = loctext + "\" 'handles the root
data_base = txt_path.Text
Set tr_db = OpenDatabase(data_base)
Set letter_set = tr_db.CreateDynaset("letter")
AccessLevel = 0
SQL = "Select AccessLevel from UserAccessLevel where LoginID = '" & usr_id & "'"
Set myAccess = tr_db.CreateDynaset(SQL)
If myAccess.RecordCount > 0 Then
AccessLevel = myAccess("AccessLevel")
Else
AccessLevel = 1
End If
myAccess.Close
db_path = txt_path.Text
MainMenu.Show
Unload Form1
Exit Sub
err_hand:
MsgBox (Error)
txtID.Text = ""
txtPassword.Text = ""
txtID.SetFocus
Exit Sub
End Sub
-
Jan 5th, 2001, 08:33 AM
#2
Lively Member
Check your msdn for dao examples
Code:
Sub DatabaseObjectX()
Dim wrkJet As Workspace
Dim dbsNorthwind As Database
Dim dbsNew As Database
Dim dbsLoop As Database
Dim prpLoop As Property
Set wrkJet = CreateWorkspace("JetWorkspace", "admin", _
"", dbUseJet)
' Make sure there isn't already a file with the name of
' the new database.
If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"
' Create a new database with the specified
' collating order.
Set dbsNew = wrkJet.CreateDatabase("NewDB.mdb", _
dbLangGeneral)
Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb")
' Enumerate the Databases collection.
For Each dbsLoop In wrkJet.Databases
With dbsLoop
Debug.Print "Properties of " & .Name
' Enumerate the Properties collection of each
' Database object.
For Each prpLoop In .Properties
If prpLoop <> "" Then Debug.Print " " & _
prpLoop.Name & " = " & prpLoop
Next prpLoop
End With
Next dbsLoop
dbsNew.Close
dbsNorthwind.Close
wrkJet.Close
End Sub
-
Jan 5th, 2001, 08:45 AM
#3
Fanatic Member
The reference to the workgroup information file is the securtiy.mdb that Access uses to secure databases. You need to pass the location and name of that file in to the connection string when connecting to the database. It is listed as one of the extended properties. There are other threads on this in the Database forum. Try a search in there.
Cheers,
P.
Not nearly so tired now...
Haven't been around much so be gentle...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|