DefaultUser, DefaultPassword Properties
Applies To
DBEngine object.
Description
- DefaultUser — sets the user name used to create the default Workspace when it is initialized.
- DefaultPassword — sets the password used to create the default Workspace when it is initialized.
Settings
The setting for DefaultUser is a String data type. It can be 1–20 characters long in Microsoft Jet workspaces and any length in ODBCDirect workspaces, and it can include alphabetic characters, accented characters, numbers, spaces, and symbols except for: " (quotation marks), / (forward slash), \ (backslash), [ ] (brackets), : (colon), | (pipe), < (less-than sign), > (greater-than sign), + (plus sign), = (equal sign), ; (semicolon), , ( comma), ? (question mark), * (asterisk), leading spaces, and control characters (ASCII 00 to ASCII 31).
The setting for DefaultPassword is a String data type that can be up to 14 characters long in Microsoft Jet databases and any length in ODBCDirect connections. It can contain any character except ASCII 0.
By default, the DefaultUser property is set to "admin" and the DefaultPassword property is set to a zero-length string (" ").
Remarks
User names aren't usually case-sensitive; however, if you're re-creating a user account that was deleted or created in a different workgroup, the user name must be an exact case-sensitive match of the original name. Passwords are case-sensitive.
Typically, you use the CreateWorkspace method to create a Workspace object with a given user name and password. However, for backward compatibility with earlier versions and for convenience when you don't implement a secured database, the Microsoft Jet database engine automatically creates a default Workspace object when needed if one isn't already open. In this case, the DefaultUser and DefaultPassword property values define the user and password for the default Workspace object.
For this property to take effect, you should set it before calling any DAO methods.
Example
This example sets the DefaultUser and DefaultPassword properties which will determine the settings for the default Workspace object.
Sub DefaultUserX()
' Set the DefaultUser and DefaultPassword properties for
' the DBEngine object.
DBEngine.DefaultUser = "NewUser"
DBEngine.DefaultPassword = ""
Debug.Print _
"Setting DBEngine.DefaultUser to 'NewUser'..."
Debug.Print _
"Setting DBEngine.DefaultPassword to " & _
"[zero-length string]..."
Dim wrkJet As Workspace
Dim wrkLoop As Workspace
Dim prpLoop As Property
Set wrkJet = CreateWorkspace("JetWorkspace", "admin", _
"", dbUseJet)
' Enumerate Workspaces collection.
On Error Resume Next
For Each wrkLoop In Workspaces
Debug.Print "Workspace: " & wrkLoop.Name
' Enumerate Properties collection of each Workspace
' object.
For Each prpLoop In wrkLoop.Properties
Debug.Print " " & prpLoop.Name & " = " & prpLoop
Next prpLoop
Next wrkLoop
On Error GoTo 0
wrkJet.Close
End Sub