Finding Items Using SQL (VB.NET)

Finding Items Using SQL (VB.NET)
 1MyApp = None
 2
 3# MyApp = CreateObject("impact.Application")
 4
 5# ensure that impact is running and has an active database connection
 6if not MyApp.isNone():
 7    MyDb = None
 8    MyDb = MyApp.active_database
 9
10    if not MyDb.isNone():
11        Items = None
12        ProjItem = None
13
14        # a simple query
15        StrSQL = None
16        Items = MyDb.find_items_by_sql(ipDrawingType.dtProject, StrSQL)
17
18        # Wrap variant return items with Impact.py wrapper
19        if Items is not None:
20            Items = [IDatabaseItem(item) for item in Items]
21
22        # output the results to a textbox on the form
23        TextBox1.append_text(str(Items.length) + " items found." + "\r\n")
24        for ProjItem in Items:
25            TextBox1.append_text(str(ProjItem.reference) + "\r\n")
26