Hi,
i am trying to return data table from a function to a variable. This is what I did:
function get-data{
#connection open and using sql command with stored procedure and parameters to that stored #procedure
# opening adapter and retuning data table.
# when I try for get type, it shows as it is sending data table
[System.Data.DataTable] $dt = New-Object System.Data.DataTable
$sqlDataAdapter.Fill($dt) | Out-Null
$sqlConnection.Close()
return ,$dt
}
$returnAccounts = get-data
$returnAccounts.GetType().FullName
Why I am getting system.object type.
Here is the output:
it is giving me all stored procedure parameters list in addition to data
CompareInfo : None
XmlSchemaCollectionDatabase :
XmlSchemaCollectionOwningSchema :
XmlSchemaCollectionName :
ForceColumnEncryption : False
DbType : String
LocaleId : 0
ParameterName : @pStartDate
Precision : 0
Scale : 0
SqlDbType : NVarChar
SqlValue : 2025-06-01
UdtTypeName :
TypeName :
Value : 2025-06-01
Direction : Input
IsNullable : False
Offset : 0
Size : 10
SourceColumn :
SourceColumnNullMapping : False
SourceVersion : Current
why is it happening. Do I have to loop through and check for datarow type and add to new table?
TIA