Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 412
  • Last Modified:

VB.net List all query name in an Access database

Hi

What VB.net code would I use to add all the query names in an Access database to a
ComboBox. I use a connection string to connect to the Access Database

Thanks
0
Murray Brown
Asked:
Murray Brown
1 Solution
 
käµfm³d 👽Commented:
If you add a reference to the "Microsoft Access 14.0 Object Library", or whichever version you have installed, then you should be able to open the database and loop over the queries using something like:

Module Module1

    Sub Main()
        Dim y As New Microsoft.Office.Interop.Access.Dao.DBEngine()
        Dim x As Microsoft.Office.Interop.Access.Dao.Database = y.OpenDatabase("C:\path\to\database.accdb")

        For Each query As Microsoft.Office.Interop.Access.Dao.QueryDef In x.QueryDefs
            Console.WriteLine(query.Name)
        Next

        Console.ReadKey()
    End Sub

End Module

Open in new window

0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now