Mark: I hope you don't mind. I add the full code. For those like me who struggle with VB. :)
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
Imports OneStream.Shared.Common
Imports OneStream.Shared.Database
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Wcf
Imports OneStream.Stage.Database
Imports OneStream.Stage.Engine
Namespace OneStream.BusinessRule.Extender.SJP_GIGChk 'Your Extensibility Rule must be the same name.
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
Try
'Hi, you can check an individual database size With an extensibility rule containing code Like this:
Dim sql As String = "EXEC sp_spaceused;"
Dim dbConnApp As DbConnInfoApp = brapi.Database.CreateApplicationDbConnInfo(si)
Using dbConnApp
Using dt As DataTable = BRAPi.Database.ExecuteSql(dbConnApp, sql.ToString, True)
If Not dt Is Nothing Then
'Reference dt to access data table results
For Each dr As DataRow In dt.Rows
'Process rows
brapi.ErrorLog.LogMessage(si, "database_size: " + dr("database_size"))
brapi.ErrorLog.LogMessage(si, "unallocated space: " + dr("unallocated space"))
Next
End If
End Using
End Using
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace