2014-02-12 21 views
0

我有腳本,連接到數據庫。我需要獲取有關執行腳本的技術信息。或者當我在sql srcipt中存在錯誤時,我看到的信息非常少。但我需要詳細的錯誤。我如何獲得更多詳細信息?在SQL上打開詳細診斷執行powershell

$connection = New-Object System.Data.SqlClient.SqlConnection 
    $connection.ConnectionString = $connectionString 
    $connection.Open() 
    $query = "SELECT * FROM Animal" 
    $command = $connection.CreateCommand() 
    $command.CommandText = $query 
    $result = $command.ExecuteReader() 
    $table = new-object 「System.Data.DataTable」 
    $table.Load($result) 
    $table 
      //how get info 
    $connection.Close() 

回答

0

在您的代碼執行後,運行Error[0] | fl -Force以獲取(上次)錯誤的詳細信息。