Powershell ADODB Recordset getstring comma separated RRS feed

  • Question

  • I am having problems with the getstring method of the Adodb.recordset object in Powershell 

    I wish to output a comma-separated string of a persisted recordset. I am not entirely sure the correct syntax for the getstring method 

    when I write the following


    I get the following error

    Missing ')' in method call.
    At :line:1 char:25
    + $objRecordset.Getstring(, <<<< ,",",,)

    The full code is below

    $adOpenStatic = 3 $adLockOptimistic = 3 $objRecordset = New-Object -comobject ADODB.Recordset ## where Modeldata.rs is recordset save to ADTG file $objRecordset.Open("Modeldata.rs" , "Provider=MSPersist",$adOpenStatic,$adLockOptimistic)

    $objRecordset.MoveFirst() ## outputs a tab delimited string by default $objRecordset.Getstring() ## output a comma delimited string $objRecordset.Getstring(,,",",,) ## returns the following error ##Missing ')' in method call. ##At :line:1 char:25 ##+ $objRecordset.Getstring(, <<<< ,",",,) $objRecordset.Close()

    Can you please help?

    If this is not possible, is there a suitable workaround? 

    Monday, December 16, 2013 11:47 PM


  • Thanks, jrv. That set me on the right track. I discovered also that I needed to enter a value for the second parameter (NumRows) as well. To return all records, I need to enter -1. 


    • Marked as answer by Magpie1990 Tuesday, December 17, 2013 6:57 AM
    Tuesday, December 17, 2013 6:57 AM

All replies