Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse DAO to list database properties and their values
DescriptionThis example shows how to use DAO to list database properties and their values in Visual Basic 6.
KeywordsDAO, database, property, database property, database properties
CategoriesDatabase
 
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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated