Finding Items Using SQL (VB.NET)¶
Finding Items Using SQL (VB.NET)¶
1import win32com.client
2my_app = None
3my_app = win32com.client.Dispatch("impact.Application")
4
5# ensure that impact is running and has an active database connection
6if not my_app.isNone():
7 my_db = None
8 my_db = my_app.active_database
9
10 if not my_db.isNone():
11 items = None
12 proj_item = None
13
14 # a simple query
15 str_sql = None
16 items = my_db.find_items_by_sql(ipDrawingType.dtProject, str_sql)
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 text_box1.append_text(str(items.length) + " items found." + "\r\n")
24 for proj_item in items:
25 text_box1.append_text(str(proj_item.reference) + "\r\n")