Loading...

Profitbase.Data.SqlCommand functions

$result = [Profitbase.Data.SqlCommand]::ExecuteNonQuery($command [,$sqlParamaters])

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

$dataTable = [Profitbase.Data.SqlCommand]::LoadTable($query [,$sqlParamaters])

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

$objectResult = [Profitbase.Data.SqlCommand]::ExecuteScalar($query [,$sqlParamaters])

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.

$dataReader = [Profitbase.Data.SqlCommand]::ExecuteReader($query [,$sqlParamaters])

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