Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

MySQL Connector 8.0.13 PowerShell .Parameters.AddWithValue() (no replies)

$
0
0
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.

Example:
$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)

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>