A question about how to display table contents by using powershell from sql database

1,493

I've done this kind of thing fairly often. Not the XML part, but pulling data out SQL via Powershell.

$SqlQuery = "SELECT Thing, Item, FROM Tablename WHERE (Item < "5")"
$SqlCmd.CommandTest=$SqlQuery
$DBResult = $DBComand.ExecuteReader()
$DataTable = New-Object system.data.datatable
$DataTable.load($DBResult)

You now have an object of type Datatable to parse through.

foreach ($Row in $DataTable) {
    [XML]$ReturnedXML=$Row.Thing()
    DoSomethingWithXML($ReturnedXML)
}
Share:
1,493

Related videos on Youtube

Irvine
Author by

Irvine

Updated on September 18, 2022

Comments

  • Irvine
    Irvine over 1 year

    I am building a “pseudo-intelligent” GUI for a gimp plugin using Glade. The main part of the GUI has two frames and imports the contents using the “reparent” method. The main objective is to have the contents of the second frame determined by the selections made in the first frame. (Eventually, the intention is to import this GUI as the content for the tabbed pages of a "notebook")

    To start with, I made a simple window, consisting of a “RadioButtonBox” and a “ComboBox” which is populated using:

    # create the cell renderer
    self.cell = gtk.CellRendererText()
    #populate the default choice into the Selection  combobox
    self.SelectionBox = self.builder.get_object("SelectionBox")
    self.SelectionBox.set_model(self.EditCommands)
    self.SelectionBox.pack_start(self.cell, True)
    self.SelectionBox.add_attribute(self.cell, 'text', 1)
    self.SelectionBox.set_active(0)
    # End: populate the selection combo box section
    

    This works and I can successfully “import” and “reparent” the simple GUI as the first frame of the larger, more complex GUI without any problems. However, as the design progressed, it has become more convenient to have the code for the first frame as an integral part of the main GUI, and this is where my problems begin.

    I have reproduced the contents of the simple GUI in the first frame of the larger GUI and copy/pasted the code from the simple GUI's “init” function. In other-words, everything is identical.

    Unfortunately, when I run the code I get the following error:

    C:\Documents and Settings\anonymous\Desktop\Glade-tutorial\BatchEditMain\BatchEditLibrary\Tab.py:46: GtkWarning: gtk_entry_set_text: assertion `text != NULL' failed
      self.SelectionBox.set_active(0)
    

    Could someone please explain what the problem is?

    Thanks in advance

    Irvine

    • andlabs
      andlabs about 9 years
      Is EditCommands populated by that point?
    • Irvine
      Irvine about 9 years
      Yes, though there is a caveat: The spacing of the list seems to be offset, so that the list is only visible in the drop down menu, not in the combobox itself.
  • pansal
    pansal over 12 years
    I tried to use get-member to list $row, I am sure $row has got what I need now. But how can I show the content form it?'StageDesc Property System.String StageDesc {get;set;} ', I can see that stagedesc is a property now, how to use it?
  • andlabs
    andlabs about 9 years
    Yes, that's the diagnosis, but that doesn't explain why it's doing that. There's nothing there that obviously uses GtkEntry (this is likely a GtkComboBox that has an entry), so more investigation is needed.
  • SiHa
    SiHa about 9 years
    No, it doesn't, because we can't see the code for SelectionBox. I've explained the slightly cryptic warning message. It should be straightforward to then find the call to gtk_entry.set_text() and track down the problem. More information is required from the OP.
  • Irvine
    Irvine about 9 years
    1) The same code works when the “combobox” is part of a simple GUI, and it continues to work when the simple GUI is reparented as part of a more complex GUI. It only ceases to work when I build the functionality directly into the more complex GUI. 2) “SelectionBox” is a GTK/Glade object defined by the line 'self.SelectionBox = self.builder.get_object("SelectionBox")' 3) 'gtk_entry.set_text()' is not directly called by my function, but part of the GTK. As a result, any legitimate resolution of the problem should not involve tracking this function down.
  • SiHa
    SiHa about 9 years
    I'm not sure I quite agree. 'gtk_entry.set_text() is called by the GLADE object, which you have defined, not some obscure inner workings of GTK. Whether you think it's legitimate or not, if you want to fix your problem, you're going to have to find why this call is failing. What happens if you try to set a different default entry (e.g. self.SelectionBox.set_active(1))? Can you dump the contents of self.EditCommands?