Loading...

Profitbase.Data.SqlScript functions

[Profitbase.Data.SqlScript]::ExecuteNonQuery

Executes the defined SQL Script against the solution database connection and returns the number of rows affected.

[Profitbase.Data.SqlScript]::LoadTable

Executes the defined SQL Script against the solution database connection and returns a data table object that contain the resulting columns and rows.

[Profitbase.Data.SqlScript]::ExecuteScalar

Executes the defined SQL Script, 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.SqlScript]::ExecuteReader

Executes the defined SQL Script against the solution database connection and returns a SqlDataReader object that can be used read field and row data.


Examples

$param1 = New-Object System.Data.SqlClient.SqlParameter('@logEntryType',
[System.Data.SqlDbType]::NVarChar)
$param1.Value = 'Warning'
[Profitbase.Data.SqlScript]::ExecuteNonQuery($PbRunContext,'NonQuerySql', $param1)

$param1 = New-Object System.Data.SqlClient.SqlParameter('@logEntryType',
[System.Data.SqlDbType]::NVarChar)
$param1.Value = 'Info'
[Profitbase.Data.SqlScript]::ExecuteScalar($PbRunContext,'ScalarSql', $param1)

$param1 = New-Object System.Data.SqlClient.SqlParameter('@logEntryType',
[System.Data.SqlDbType]::NVarChar);
$param1.Value = 'Error'
[Profitbase.Data.SqlScript]::LoadTable($PbRunContext, 'LoadTableSql', $param1)

$param1 = New-Object System.Data.SqlClient.SqlParameter('@logEntryType', [System.Data.SqlDbType]::NVarChar);
$param1.Value = 'Error'
[Profitbase.Data.SqlScript]::ExecuteReader($PbRunContext, 'ReaderSql', $param1)
$readerHadRows = $reader.HasRows
$reader.Close() # Closes reader and connection