Loading...

Profitbase.Data.SqlCommand functions

[Profitbase.Data.SqlCommand]::ExecuteNonQuery

Executes a Transact-SQL statement against the solution database connection and returns the number of rows affected.

[Profitbase.Data.SqlCommand]::LoadTable

Executes a SQL query against the solution database connection and returns a data table object that contains the resulting columns and rows.

[Profitbase.Data.SqlCommand]::ExecuteScalar

Executes a SQL query and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.

[Profitbase.Data.SqlCommand]::ExecuteReader

Executes a SQL query against the solution database connection and returns a SqlDataReader object that can be used to read field and row data. Note! The SqlDataReader object should always be closed after processing to avoid leaving database connection open longer than necessary.

Examples

[Profitbase.Data.SqlCommand]::LoadTable("SELECT * FROM [dbo].[pbInvision_PowerShellLog]")
[Profitbase.Data.SqlCommand]::ExecuteNonQuery("DELETE TOP (10) FROM [dbo].[pbInvision_PowerShellLog]")
[Profitbase.Data.SqlCommand]::ExecuteScalar("SELECT COUNT(*) FROM [dbo].[pbInvision_PowerShellLog]")
$reader = [Profitbase.Data.SqlCommand]::ExecuteReader("SELECT * FROM [dbo].[pbInvision_PowerShellLog]")
while ($reader.Read()) {
Write-Output $reader["Message"]
}
$reader.Close() # Closes reader and connection