MySQL Connector 8.0.13 PowerShell .Parameters.AddWithValue()
Posted by: Jeffrey Faulstich
Date: November 14, 2018 12:20PM

While using the MySql.Data.MySqlClient with the .Parameters.AddWithValue() for some odd reason the first argument of the AddWithValue is returned no matter what. So if you are creating a Function in PowerShell you MUST set some variable or $null to be equal to $oMySQLCommand.Parameters.AddWithValue() otherwise if you are depending on a return from the Function your value will be corrupted by the Argument being returned.

Oddly, it also does not return $false if the value is not found in the .CommandText() either so it seems to have no purpose whatsoever.

$oMySQLCommand = New-Object MySql.Data.MySqlClient.MySqlCommand
$oMySQLCommand.Connection = $oMySQLPrivilegedConnection
$oMySQLCommand.CommandText = $strMySQL_INSERT
# Must capture the .AddwithValue() else if within a Function and relying on the Return of the function you will be surprised.
$null = $oMySQLCommand.Parameters.AddWithValue("@employeeID", $employeeID)

Options: ReplyQuote

Written By
MySQL Connector 8.0.13 PowerShell .Parameters.AddWithValue()
November 14, 2018 12:20PM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.