|
|
Title | Use DAO to list database properties and their values |
Description | This example shows how to use DAO to list database properties and their values in Visual Basic 6. |
Keywords | DAO, database, property, database property, database properties |
Categories | Database |
|
|
The DAO Database object has a Properties collection that gives the names and values of the database's properties. The program loops through this collection, displaying the names and values of each property. Note that some properties have "Values" that you cannot look at so the program protects itself with an On Error statement.
|
|
Private Sub cmdGo_Click()
Dim db As DAO.Database
Dim i As Integer
Dim list_item As ListItem
Screen.MousePointer = vbHourglass
DoEvents
' Open the database.
Set db = DBEngine.Workspaces(0).OpenDatabase( _
txtDatabase.Text, ReadOnly:=False)
' List the properties.
lvwProperties.ListItems.Clear
For i = 0 To db.Properties.Count - 1
Set list_item = _
lvwProperties.ListItems.Add(Text:=db.Properties(i).Name)
On Error Resume Next
list_item.SubItems(1) = db.Properties(i).Value
If Err.Number <> 0 Then list_item.SubItems(1) = _
"?????"
On Error GoTo 0
Next i
db.Close
Screen.MousePointer = vbDefault
End Sub
|
|
|
|
|
|