2016-02-13 28 views
0

試圖從Powershell的版本4執行MySQL查詢「2」的說法(S),我得到這個錯誤:MySQL查詢異常調用「填充」從Powershell的V4

Could not run MySQL Query Exception calling "Fill" with "2" argument(s): "Fatal error encountered during command execution." 

這裏是我的SQL嘗試從Powershell。該SQL是變量$ updateReportQuery:

$updateReportQuery = "call count_changed_mark(@count_changed_mark);" 
MySQLQuery -ConnectionString $connection -query $updateReportQuery 

僅供參考,這裏是從MySQLQuery功能與其他查詢沒有問題,使用的片段:

# Run MySQL Querys 
Write-Verbose "Run MySQL Querys" 
$command = New-Object MySql.Data.MySqlClient.MySqlCommand($query, $connection) 
$dataAdapter = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($command) 
$dataSet = New-Object System.Data.DataSet 
$recordCount = $dataAdapter.Fill($dataSet, "data") 
$dataSet.Tables["data"] | Format-Table 
return $dataSet.Tables[「data」] #returns response as an object 

當我輸出功能的SQL編寫-host然後複製/粘貼SQL控制檯中的SQL,它運行良好。我只從Powershell得到錯誤。

在此先感謝您的幫助。

回答

0

問題出在用戶變量上。必須將Allow User Variables=True;添加到連接字符串。

實施例:

$connection = "Server=localhost;Uid=youruserid;Pwd=yourpassword;database=yourdatabase;Allow User Variables=True;"