In PowerShell, goal is to query some data from Sql Server and put that into a preformatted Excel file. Towards that, the following PowerShell script snippet, throws an error saying "assemblies are missing".
From what I could gather online,
SqlClient.SqlDataAdapter is part of
ADO.Net, which does not require including any assemblies (as it is always present in the OS .Net framework installation). Is this correct? How do I rectify this?
... ... other connection code ... $SqlCmd = New-Object System.Data.SqlClient.SqlCommand; $SqlCmd.Connection = $SqlConnection; $SqlCmd.CommandText = $ActiveTransactions_Count_Query; $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter; $SqlAdapter.SelectCommand = $SqlCmd; $DataSet_ActiveTransaction = New-Object System.Data.DataSet; $SqlAdapter.Fill($DataSet_ActiveTransaction); $DataSetTable = $DataSet_ActiveTransaction.Tables; $DataSetTable
New-Object : Cannot find type [Sql.Data.SqlClient.SqlDataAdapter]: make sure the assembly containing this type is loaded. At M:\Build.ps1:21 char:25 + $SqlAdapter = New-Object <<<< Sql.Data.SqlClient.SqlDataAdapter; + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand