I’m attempting to display data from a Oracle DB but not data is displayed.
Automated Script:
# Path to ODAC.NET Installation
Add-Type -Path "C:\OracleDAC\odp.net\managed\common\Oracle.ManagedDataAccess.dll"
$reader = $false
# SQL DB Username, Password and DataSource Alias (as per tnsnames.ora)
$username = "username"
$password = "password"
# Alias from TNSNames.ora
$datasource = "db"
$connectionstring = 'User Id=' + $username + ';Password=' + $password + ';Data Source=' + $datasource
#$queryStatment = "Select col1, col2, col3 from table where ROWNUM <= 10"
function Get-OracleResultRdr
{
try{
$con = New-Object Oracle.ManagedDataAccess.Client.OracleConnection($connectionstring)
$con.Open()
$cmd = $con.CreateCommand()
$cmd.CommandType = "text"
$cmd.CommandText = $queryStatment
$reader = $cmd.ExecuteReader()
$columnNames=$reader.GetSchemaTable() | Select-Object -ExpandProperty ColumnName
while ($reader.Read()) {
$result=[ordered]@{}
for ($i=0; $i -lt $reader.FieldCount; $i++) {
$result.Add($columnNames[$i], $reader.GetOracleValue($i))
}
[pscustomobject]$result
}
} catch {
Write-Error (“Database Exception: {0}`n{1}” -f `
$con.ConnectionString, $_.Exception.ToString())
} finally{
if ($con.State -eq ‘Open’) { $con.close() }
}
}
Set-PSUCache -Key "OracleTestData" -Value (Get-OracleResultRdr $connectionstring $queryStatment) -AbsoluteExpirationFromNow ([TimeSpan]::FromHours(1))
Dashboard:
New-UDDynamic -Id 'TestDynamicRegion' -Content {
New-UDRow -Columns {
New-UDColumn -LargeSize 7 -Content {
$TestTableData = Get-PSUCache -Key "OracleTestData"
$TestTableColumns = @(
New-UDTableColumn -Property col1 -Title "First Col"
New-UDTableColumn -Property col2 -Title "Second Col"
New-UDTableColumn -Property col3 -Title "Third Col"
)
New-UDTable -Title "Test" -Id "testTable" -Columns $TestTableColumns -Data $TestTableData -Sort -PageSize 25 -PageSizeOptions @(10, 25) -Search -export #-Padding default
}
}
} -AutoRefresh -AutoRefreshInterval 120
Just the column titles appear but no data. Am I missing something?
Product: PowerShell Universal
Version: 1.5.7