value can not be null error in PowerShell
Solution 1:
Don't remove the column headers, but double check how they are written.. with spaces
Your code ignores those here
$($_.HoldValue)
--> $($_.'Hold Value')
$($_.MultMID)
--> $($_.'Mult MID')
$($_.ExistOD)
--> $($_.'Exist OD')
Either keep the code and rewrite the headers (take out the spaces) or make sure you use the property names according to the headers.
By removing the column headers, the first line in the csv file wil be used as column headers unless you supply new ones with parameter -Header
. Removing headers will cause problems if the same field value is encountered more than once because column headers must be unique
Then there is this line:
$result = $db.ExecuteWithResults($csvfile)
which should be
$result = $db.ExecuteWithResults($query)
AND there is no point in looping over the records of the csv file and inside that loop overwrite your query string on every iteration so only the last record wil remain...