Check the content of
$sql
- if it refers to parameters like this:
SELECT Description FROM MyTable WHERE ID = @ID
then make sure that you have added the parameterized data to the
$cmd
object before you try to call
ExecuteReader
.
And why are you passing
ExecuteReader
a string? I'm far from a PowerShell expert and I can't find the documentation, but every example I've seen online calls it with no parameters at all ...