Я пытаюсь запустить несколько SQL-запросов и получить результат в каком-то файле txt/csv, но я получаю сообщение об ошибке, которое я не могу исправить. Любой совет?Powershell запускает несколько SQL-запросов
$dbServer = "dbserver"
$extractFile = "C:\test\" + $timer + ".csv"
$Database = "b
$User = "Admin"
$Pass = "psswd"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server=$dbServer;Database=$db;uid=$User;password=$Pass;"
$SQLConnection.Open()
$SQLCommand = $SQLConnection.CreateCommand()
$SQLCommand.CommandText =
"select count(*) 'Nombre de Address mail' FROM dbo.UsersParticipations"
"select count(*) 'Nombre de Transactions' FROM dbo.Transactions;"
$readAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$readSet = New-Object System.Data.DataSet
$readAdapter.SelectCommand = $SQLCommand
$readAdapter.Fill($readSet) |out-null
$SQLConnection.Close()
Foreach ($row in $readSet.Tables[0].rows) {
Write-Output "Adress"
Write-Output "$($row.size) $($row.job)"
}
Foreach ($row in $readSet.Tables[1].rows) {
Write-Output "Transactions"
Write-Output "$($row.free) "
}
Это ошибка, я получаю:
Exception calling "Fill" with "1" argument(s): "Invalid object name 'dbo.UsersParticipations'."
At C:\Efiester\test2.ps1:18 char:1
+ $readAdapter.Fill($readSet) |out-null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SqlException
что Ошибка? – Jayvee
Исключение, вызывающее «Заполнить» аргументом «1»: «Недопустимое имя объекта» dbo.UsersParticipations ». В C: \ Efiester \ test2.ps1: 18 char: 1 + $ readAdapter.Fill ($ readSet) | out-null + ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ + CategoryInfo: NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId: SqlException – Raul
добавлено сообщение об ошибке из комментария –