Exception calling "Open" with "0" argument(s): "Cannot open database "hmaildb" requested by the login. The login failed. Login failed for user 'ladadbm'." At D:\Media\hmail_tables.ps1:3 char:1 + $conn.Open() + ~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SqlException Exception calling "ExecuteReader" with "0" argument(s): "ExecuteReader requires an open and available Connection. The connection's current state is closed." At D:\Media\hmail_tables.ps1:6 char:1 + $rd=$cmd.ExecuteReader() + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : InvalidOperationException You cannot call a method on a null-valued expression. At D:\Media\hmail_tables.ps1:8 char:7 + while($rd.Read()){$cnt++;Write-Output $rd[0]} + ~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At D:\Media\hmail_tables.ps1:9 char:1 + $rd.Close() + ~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Total tables: 0