Search the Community
Showing results for tags 'Sql query'.
-
I have been working on a project that pulls information from a sql database (Microsoft SCCM), and then presents a GUI to the end user to manipulate that data. On startup, the application pulls a list of collections of computers the user has access to. Currently I pull in a web report, save it as a .csv, and then convert the sheet to a 2d array. This works very well, but is a bit cumbersome. It adds 5-10 seconds onto the startup, which to the end user seems to be a lag, since I cannot create the GUI until this array is created. I can query the database directly, and get the same information far more quickly in just a few lines of code (see below). I'm just unsure how to easily convert this into a 2d array any other way than the Excel trick I am using above. From the Help file, _ArrayAdd is for a 1D array only. Am I overlooking something obvious, or is the Excel method the best option? I can easily pull the query, and use the $element.Name and $element.CollectionID properties, but would like to have them in an Array for use in the rest of the application. $sServer = "SCCMP02" $SCode = "P02" $oLocator = ObjCreate("WbemScripting.SWbemLocator") Global $oSMS = $oLocator.ConnectServer($sServer, "root\sms\site_" & $SCode) If @error Then MsgBox(0, "", "Can't Connect") $oSMS.Security_.ImpersonationLevel = 3 $oSMS.Security_.AuthenticationLevel = 6 $oResults = $oSMS.ExecQuery("SELECT * FROM SMS_Collection WHERE Comment LIKE '%Site License%' ORDER by Name") For $element In $oResults $name = $element.Name $colID = $element.CollectionID MsgBox(0, $name, $colID) Next