I have this code in PowerShell that executes an SQL query for an UPDATE table:
$Connection=new-object data.sqlclient.sqlconnection "server=server;database=mydb;trusted_connection=true;"
$Connection.open()
For( $i = 0; $i -le $ActID.Length; $i ++ ){
$cmd = New-Object System.Data.SqlClient.SqlCommand
$cmd.Connection = $Connection
$cmd.CommandText =
"
update Table
set Note = @PATH
"
$cmd.Parameters.Add("@PATH", $ActID[$i].Values) | Out-Null
$cmd.ExecuteNonQuery()
}
I am trying to update a table with the variable defined in this row:
$cmd.Parameters.Add("@PATH", $ActID[$i].Values) | Out-Null
But when I try to execute the script, the error log says that in $ ActID [$ i]
no valueAre there other methods for passing parameters (variables) in powershell requests?
user273579
source
share