11 December,2019 by Tom Collins
Question: I'm building a Powershell form GUI utilising the System.Windows.Forms API.
I'm getting an error when passing text value back to be processed from a text box defined by :
$CommentsTxtBox = New-Object System.Windows.Forms.TextBox
Exception calling "ExecuteReader" with "0" argument(s): "Incorrect syntax near 'mytext'."
When I then take the space out of the Comments value – i.e change “New Value” to “NewValue” I get the New value generated message. So the space within the text value is generating the error
How can I fix?
Answer: The quick answer is to place ' ' around the incoming value where you are processing the form values. For example :
function myFormProcess
{
$comments = $Comment
$SqlCmdqip = "Exec Generate_New '$comments' "
}
If you would like to know how to dig into Powershell read - Expand your Powershell mind – Three key cmdlets
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |