La Commande Sql (à l'Exception de l'appel “ExecuteScalar” avec “0” argument)

Lorsque j'exécute le code ci-dessous sur la première tentative, j'obtiens une erreur inexpliquée, mais l'exécution du script à nouveau lors d'une deuxième tentative fonctionne très bien...ce serait une erreur dans mon code?

Par la façon dont je suis la création de la base de données avant cette étape...

  $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
  $SqlConnection.ConnectionString = "Server=$dBServer;Database=$dBName;Integrated Security=True" 
  $SqlConnection.Open() 

  $SqlCmd = New-Object System.Data.SqlClient.SqlCommand 
  $SqlCmd.CommandText = $dBCmd 
  $SqlCmd.Connection = $sqlConnection 

  $execute = $SqlCmd.ExecuteScalar() 
  $SqlConnection.Close() 

Erreur

Exception calling "ExecuteScalar" with "0" argument(s): "A transport-level error has occurred when sending the request to the server. (provider: Shared Memory  Provider, error: 0 - No process is on the other end of the pipe.)" At c:\scripts\DB\Powershell\RunSql.ps1:61 char:34
+   $execute = $sqlCmd.ExecuteScalar <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
InformationsquelleAutor Ozie Harb | 2010-03-04