Getting Datagridview to Populate Correctly

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
TechGy
Posts: 3
Last visit: Wed Jun 20, 2018 11:07 am

Getting Datagridview to Populate Correctly

Post by TechGy »

I have a GUI application designed that includes a button and a datagridview box. The button click event loads the datagridview box. Unfortunately I can't get the datagridview box to populate with information

Button Click Code:
  1. $buttonStep2LoadSoftwareLis_Click={
  2.     #Send PDQ server command to list all PDQ Deploy packages via Powershell Remoting
  3.     $packages = Invoke-Command -ComputerName $PDQServerName -Credential (Get-Credential) { "SELECT Packages.Name from Packages;" | sqlite3.exe "C:\ProgramData\Admin Arsenal\PDQ Deploy\Database.db" }
  4.     $table = ConvertTo-DataTable -InputObject $packages
  5.     #Load the Software List
  6.     Update-DataGridView -DataGridView $datagridview1 -Item $table
  7. }

You can see what the form outputs in the Datagridview_Click_Output.png attachment in this post
You can see what the command outputs in the PS_Output.png


Can someone help me get this into a format that loads the datagridview box with the information like it's output when running the command in Powershell?
Attachments
PS_Output.PNG
PS_Output.PNG (13.3 KiB) Viewed 1272 times
Datagridview_Click_Output.PNG
Datagridview_Click_Output.PNG (22.9 KiB) Viewed 1272 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Getting Datagridview to Populate Correctly

Post by jvierra »

The output of your query is text and not objects. You muse use a command based of OLEDB.Net and the System.Data.OleDbClient. The sqllite EXE cannot create objects.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Getting Datagridview to Populate Correctly

Post by jvierra »

Here is an article from MS showing how to access SQLLite databases from PowerShell using the SQLLite provider.

https://social.technet.microsoft.com/wi ... bases.aspx
This topic is 6 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked