Will "the Mighty" Strohl

FREE CODE: DNN v4.05.03 SqlDataProvider Optimization

I have a great need for a current project to optimize whereever I can.  The DotNetNuke SqlDataProvider is one of those areas where optimizations are NEEDED.

As of right now, I have only optimized the string portions of the code.  I replaced the normal concatenation with String.Concat() and am also using String comparison instead of strString <> "".  Oh yeah, and you cannot forget to use StringBuilders!  :)

There is also a few mail methods leftover in there from a script I had inserted to show me some information during troubleshooting something. There are certainly better implementations for it, but like I said, it was just for some real quick troubleshooting. I suggest removing it if you aren't going to use it.

There is much more to be done...  Check it out and enjoy!  (The DOWNLOAD is available at the bottom.)


Imports System
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports Microsoft.ApplicationBlocks.Data
Imports System.IO
Imports System.Text
Imports System.Web
Imports DotNetNuke
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Framework.Providers
Imports DotNetNuke.Entities.Users
Namespace DotNetNuke.Data
    Public Class SqlDataProvider
        Inherits DataProvider
#Region "Private Members"
        Private Const ProviderType As String = "data"
        Private p_providerConfiguration As ProviderConfiguration = ProviderConfiguration.GetProviderConfiguration(ProviderType)
        Private p_connectionString As String = String.Empty
        Private p_providerPath As String = String.Empty
        Private p_objectQualifier As String = String.Empty
        Private p_databaseOwner As String = String.Empty
        Private p_upgradeConnectionString As String = String.Empty
        Private p_DbOwnerQualifier As String = String.Empty
#End Region
#Region "Constructors"
        Sub New()
            Try
                ' Read the configuration specific information for this provider
                Dim objProvider As DotNetNuke.Framework.Providers.Provider = _
                    CType(p_providerConfiguration.Providers(p_providerConfiguration.DefaultProvider), DotNetNuke.Framework.Providers.Provider)
                ' Read the attributes for this provider
                'Get Connection string from web.config
                p_connectionString = DotNetNuke.Common.Utilities.Config.GetConnectionString()
                If String.IsNullOrEmpty(p_connectionString) Then
                    ' Use connection string specified in provider
                    p_connectionString = objProvider.Attributes("connectionString")
                End If
                If Not String.IsNullOrEmpty(Convert.ToString(objProvider.Attributes("upgradeConnectionString"))) Then
                    p_upgradeConnectionString = objProvider.Attributes("upgradeConnectionString")
                Else
                    p_upgradeConnectionString = p_connectionString
                End If
                p_providerPath = DotNetNuke.Common.Utilities.Config.GetProviderPath(ProviderType)
                p_objectQualifier = DotNetNuke.Common.Utilities.Config.GetObjectQualifer()
                p_databaseOwner = DotNetNuke.Common.Utilities.Config.GetDataBaseOwner()
                p_DbOwnerQualifier = String.Concat(p_databaseOwner, p_objectQualifier)
            Catch ex As Exception
                SendExceptionToAdmin(ex)
                Throw ex
            End Try
        End Sub
#End Region
#Region "Public Properties"
        ReadOnly Property ConnectionString() As String
            Get
                Return p_connectionString
            End Get
        End Property
        ReadOnly Property ProviderPath() As String
            Get
                Return p_providerPath
            End Get
        End Property
        ReadOnly Property ObjectQualifier() As String
            Get
                Return p_objectQualifier
            End Get
        End Property
        ReadOnly Property DatabaseOwner() As String
            Get
                Return p_databaseOwner
            End Get
        End Property
        ReadOnly Property UpgradeConnectionString() As String
            Get
                Return p_upgradeConnectionString
            End Get
        End Property
        ReadOnly Property DbOwnerQualifier() As String
            Get
                Try
                    Return p_DbOwnerQualifier
                Catch ex As Exception
                    SendExceptionToAdmin(ex)
                    Return String.Empty
                End Try
            End Get
        End Property
#End Region
#Region "Private Methods"
        Private Sub ExecuteADOScript(ByVal trans As SqlTransaction, ByVal SQL As String)
            'Get the connection
            Dim connection As SqlConnection = trans.Connection
            'Create a new command (with no timeout)
            Dim command As New SqlCommand(SQL, trans.Connection)
            command.Transaction = trans
            command.CommandTimeout = 0
            command.ExecuteNonQuery()
        End Sub
        Private Sub ExecuteADOScript(ByVal SQL As String)
            'Create a new connection
            Dim connection As New SqlConnection(UpgradeConnectionString)
            'Create a new command (with no timeout)
            Dim command As New SqlCommand(SQL, connection)
            command.CommandTimeout = 0
            connection.Open()
            command.ExecuteNonQuery()
            connection.Close()
        End Sub
        Private Function GetRoleNull(ByVal RoleID As Integer) As Object
            If RoleID.ToString = DotNetNuke.Common.Globals.glbRoleNothing Then
                Return DBNull.Value
            Else
                Return RoleID
            End If
        End Function
#End Region
#Region "Generic Methods"
        'Generic Methods
        '===============
        '
        ''' -----------------------------------------------------------------------------
        '''
        ''' ExecuteReader executes a stored procedure or "dynamic sql" statement, against
        ''' the database
        '''
        '''
        '''
        ''' The name of the Stored Procedure to Execute
        ''' An array of parameters to pass to the Database
        '''
        '''  [cnurse] 12/11/2005 created
        '''
        ''' -----------------------------------------------------------------------------
        Overrides Sub ExecuteNonQuery(ByVal ProcedureName As String, ByVal ParamArray commandParameters() As Object)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName(ProcedureName), commandParameters)
        End Sub
        Overrides Function ExecuteReader(ByVal ProcedureName As String, ByVal ParamArray commandParameters() As Object) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, QueryName(ProcedureName), commandParameters)
        End Function
        Overrides Function ExecuteScalar(ByVal ProcedureName As String, ByVal ParamArray commandParameters() As Object) As Object
            Return SqlHelper.ExecuteScalar(ConnectionString, QueryName(ProcedureName), commandParameters)
        End Function
        Overrides Function ExecuteSql(ByVal strSql As String) As IDataReader
            Return ExecuteSql(strSql, Nothing)
        End Function
        Overrides Function ExecuteSql(ByVal strSql As String, ByVal ParamArray commandParameters() As IDataParameter) As IDataReader
            SendMailToAdmin(String.Concat("ExecuteSql(", strSql, ") ENTERED"), String.Concat("ExecuteSql(", strSql, ") ENTERED"))
            Dim sqlCommandParameters() As SqlParameter = Nothing
            If Not commandParameters Is Nothing Then
                sqlCommandParameters = New SqlParameter(commandParameters.Length - 1) {}
                For intIndex As Integer = 0 To commandParameters.Length - 1
                    sqlCommandParameters(intIndex) = CType(commandParameters(intIndex), SqlParameter)
                Next
            End If
            strSql = strSql.Replace("{databaseOwner}", DatabaseOwner)
            strSql = strSql.Replace("{objectQualifier}", ObjectQualifier)
            SendMailToAdmin(String.Concat("FINAL strSql = ", strSql), String.Concat("FINAL strSql = ", strSql))
            Try
                Return CType(SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, strSql, sqlCommandParameters), IDataReader)
            Catch ex As Exception
                SendExceptionToAdmin(ex)
                ' error in SQL query
                Return Nothing
            End Try
        End Function
#End Region
#Region "Abstract Method Implementation"
#Region "General Methods"
        Overrides Function GetConnectionStringBuilder() As DbConnectionStringBuilder
            Return New SqlConnectionStringBuilder
        End Function
        Overrides Function GetNull(ByVal Field As Object) As Object
            Return DotNetNuke.Common.Utilities.Null.GetNull(Field, System.DBNull.Value)
        End Function
#End Region
#Region "Install/Upgrade Methods"
        Overloads Overrides Function ExecuteScript(ByVal Script As String) As String
            Return ExecuteScript(Script, False)
        End Function
        Overloads Overrides Function ExecuteScript(ByVal Script As String, ByVal UseTransactions As Boolean) As String
            Try
                Dim strSql As String = String.Empty
                'Dim Exceptions As String = String.Empty
                Dim sbExceptions As New StringBuilder
                Dim Delimiter As String = String.Concat("GO", Microsoft.VisualBasic.ControlChars.CrLf)
                Dim arrSQL As String() = Split(Script, Delimiter, , CompareMethod.Text)
                If UseTransactions Then
                    Dim Conn As New SqlConnection(UpgradeConnectionString)
                    Conn.Open()
                    Try
                        Dim Trans As SqlTransaction = Conn.BeginTransaction
                        Dim IgnoreErrors As Boolean
                        For Each strSql In arrSQL
                            If Not String.IsNullOrEmpty(strSql) Then
                                ' script dynamic substitution
                                strSql = strSql.Replace("{databaseOwner}", DatabaseOwner)
                                strSql = strSql.Replace("{objectQualifier}", ObjectQualifier)
                                IgnoreErrors = False
                                If strSql.Trim.StartsWith("{IgnoreError}") Then
                                    IgnoreErrors = True
                                    strSql = strSql.Replace("{IgnoreError}", String.Empty)
                                End If
                                Try
                                    ExecuteADOScript(Trans, strSql)
                                Catch objException As SqlException
                                    If Not IgnoreErrors Then
                                        sbExceptions.Append(ExceptionString(objException, strSql))
                                    End If
                                End Try
                            End If
                        Next
                        If sbExceptions.ToString.Length = 0 Then
                            'No exceptions so go ahead and commit
                            Trans.Commit()
                        Else
                            'Found exceptions, so rollback db
                            Trans.Rollback()
                            With sbExceptions
                                .Append("SQL Execution failed.  Database was rolled back")
                                .Append(Environment.NewLine)
                                .Append(Environment.NewLine)
                                .Append(strSql)
                                .Append(Environment.NewLine)
                                .Append(Environment.NewLine)
                            End With
                        End If
                    Finally
                        Conn.Close()
                    End Try
                Else
                    For Each strSql In arrSQL
                        If Not String.IsNullOrEmpty(strSql) Then
                            ' script dynamic substitution
                            strSql = strSql.Replace("{databaseOwner}", DatabaseOwner)
                            strSql = strSql.Replace("{objectQualifier}", ObjectQualifier)
                            Try
                                ExecuteADOScript(strSql)
                            Catch objException As SqlException
                                sbExceptions.Append(ExceptionString(objException, strSql))
                            End Try
                        End If
                    Next
                End If
                ' if the upgrade connection string is specified
                If Not String.Equals(UpgradeConnectionString, ConnectionString) Then
                    Try
                        ' grant execute rights to the public role for all stored procedures. This is
                        ' necesary because the UpgradeConnectionString will create stored procedures
                        ' which restrict execute permissions for the ConnectionString user account.
                        sbExceptions.Append(GrantStoredProceduresPermission("EXECUTE", "public"))
                    Catch objException As SqlException
                        sbExceptions.Append(ExceptionString(objException, strSql))
                    End Try
                    Try
                        ' grant execute or select rights to the public role for all user defined functions based
                        ' on what type of function it is (scalar function or table function). This is
                        ' necesary because the UpgradeConnectionString will create user defined functions
                        ' which restrict execute permissions for the ConnectionString user account.
                        sbExceptions.Append(GrantUserDefinedFunctionsPermission("EXECUTE", "SELECT", "public"))
                    Catch objException As SqlException
                        sbExceptions.Append(ExceptionString(objException, strSql))
                    End Try
                End If
                Return sbExceptions.ToString
            Catch ex As Exception
                SendExceptionToAdmin(ex)
                Return String.Empty
            End Try
        End Function
        Overrides Function FindDatabaseVersion(ByVal Major As Integer, ByVal Minor As Integer, ByVal Build As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(UpgradeConnectionString, QueryName("FindDatabaseVersion"), Major, Minor, Build), IDataReader)
        End Function
        Overrides Function GetDatabaseVersion() As IDataReader
            Return CType(SqlHelper.ExecuteReader(UpgradeConnectionString, QueryName("GetDatabaseVersion")), IDataReader)
        End Function
        Overrides Function GetProviderPath() As String
            SendMailToAdmin("BEGIN GetProviderPath()", "BEGIN GetProviderPath()")
            Try
                Dim objHttpContext As HttpContext = HttpContext.Current
                GetProviderPath = ProviderPath
                If Not String.IsNullOrEmpty(GetProviderPath) Then
                    SendMailToAdmin("GetProviderPath Is Null or Empty", "GetProviderPath Is Null or Empty")
                    GetProviderPath = objHttpContext.Server.MapPath(GetProviderPath)
                    If Directory.Exists(GetProviderPath) Then
                        SendMailToAdmin("DIRECTORY EXISTS", "DIRECTORY EXISTS")
                        Try
                            ' check if database is initialized
                            Dim dr As IDataReader = GetDatabaseVersion()
                            dr.Close()
                        Catch
                            ' initialize the database
                            Dim objStreamReader As StreamReader
                            objStreamReader = File.OpenText(String.Concat(GetProviderPath, "00.00.00.", p_providerConfiguration.DefaultProvider))
                            Dim strScript As String = objStreamReader.ReadToEnd
                            objStreamReader.Close()
                            If Not String.IsNullOrEmpty(ExecuteScript(strScript)) Then
                                GetProviderPath = "ERROR: Could not connect to database specified in connectionString for SqlDataProvider"
                            End If
                        End Try
                    Else
                        SendMailToAdmin("DIRECTORY DOESN'T EXIST", "DIRECTORY DOESN'T EXIST")
                        GetProviderPath = String.Concat("ERROR: providerPath folder ", GetProviderPath, " specified for SqlDataProvider does not exist on web server")
                    End If
                Else
                    SendMailToAdmin("GetProviderPath Is NOT Null or Empty", "GetProviderPath Is NOT Null or Empty")
                    GetProviderPath = "ERROR: providerPath folder value not specified in web.config for SqlDataProvider"
                End If
            Catch ex As Exception
                SendExceptionToAdmin(ex)
                Throw ex
            End Try
            SendMailToAdmin("END GetProviderPath()", String.Concat("GetProviderPath = ", GetProviderPath))
        End Function
        Private Function GrantStoredProceduresPermission(ByVal Permission As String, ByVal LoginOrRole As String) As String
            'Dim SQL As String = String.Empty
            Dim sbSql As New StringBuilder
            Dim Exceptions As String = String.Empty
            Try
                ' grant rights to a login or role for all stored procedures
                With sbSql
                    .Append("declare @exec nvarchar(2000) ")
                    .Append("declare @name varchar(150) ")
                    .Append("declare sp_cursor cursor for select o.name as name ")
                    .Append("from dbo.sysobjects o ")
                    .Append("where ( OBJECTPROPERTY(o.id, N'IsProcedure') = 1 or OBJECTPROPERTY(o.id, N'IsExtendedProc') = 1 or OBJECTPROPERTY(o.id, N'IsReplProc') = 1 ) ")
                    .Append("and OBJECTPROPERTY(o.id, N'IsMSShipped') = 0 ")
                    .Append("and o.name not like N'#%%' ")
                    .Append("and (left(o.name,len('")
                    .Append(ObjectQualifier)
                    .Append("')) = '")
                    .Append(ObjectQualifier)
                    .Append("' or left(o.name,7) = 'aspnet_') ")
                    .Append("open sp_cursor ")
                    .Append("fetch sp_cursor into @name ")
                    .Append("while @@fetch_status >= 0 ")
                    .Append("begin")
                    .Append("  select @exec = 'grant ")
                    .Append(Permission)
                    .Append(" on ' +  @name  + ' to ")
                    .Append(LoginOrRole)
                    .Append("'")
                    .Append("  execute (@exec)")
                    .Append("  fetch sp_cursor into @name ")
                    .Append("end ")
                    .Append("deallocate sp_cursor")
                End With
                SqlHelper.ExecuteNonQuery(UpgradeConnectionString, CommandType.Text, sbSql.ToString)
            Catch objException As SqlException
                SendExceptionToAdmin(objException)
                Exceptions = ExceptionString(objException, sbSql.ToString())
            End Try
            Return Exceptions
        End Function
        Private Function GrantUserDefinedFunctionsPermission(ByVal ScalarPermission As String, ByVal TablePermission As String, ByVal LoginOrRole As String) As String
            Dim sbSql As New StringBuilder
            Dim Exceptions As String = String.Empty
            Try
                ' grant EXECUTE rights to a login or role for all functions
                With sbSql
                    .Append("declare @exec nvarchar(2000) ")
                    .Append("declare @name varchar(150) ")
                    .Append("declare @isscalarfunction int ")
                    .Append("declare @istablefunction int ")
                    .Append("declare sp_cursor cursor for select o.name as name, OBJECTPROPERTY(o.id, N'IsScalarFunction') as IsScalarFunction ")
                    .Append("from dbo.sysobjects o ")
                    .Append("where ( OBJECTPROPERTY(o.id, N'IsScalarFunction') = 1 OR OBJECTPROPERTY(o.id, N'IsTableFunction') = 1 ) ")
                    .Append("and OBJECTPROPERTY(o.id, N'IsMSShipped') = 0 ")
                    .Append("and o.name not like N'#%%' ")
                    .Append("and (left(o.name,len('")
                    .Append(ObjectQualifier)
                    .Append("')) = '")
                    .Append(ObjectQualifier)
                    .Append("' or left(o.name,7) = 'aspnet_') ")
                    .Append("open sp_cursor ")
                    .Append("fetch sp_cursor into @name, @isscalarfunction ")
                    .Append("while @@fetch_status >= 0 ")
                    .Append("begin ")
                    .Append("if @IsScalarFunction = 1 ")
                    .Append("begin")
                    .Append("  select @exec = 'grant ")
                    .Append(ScalarPermission)
                    .Append(" on ' +  @name  + ' to ")
                    .Append(LoginOrRole)
                    .Append("'")
                    .Append("  execute (@exec)")
                    .Append("  fetch sp_cursor into @name, @isscalarfunction  ")
                    .Append("end ")
                    .Append("else ")
                    .Append("begin")
                    .Append("  select @exec = 'grant ")
                    .Append(TablePermission)
                    .Append(" on ' +  @name  + ' to ")
                    .Append(LoginOrRole)
                    .Append("'")
                    .Append("  execute (@exec)")
                    .Append("  fetch sp_cursor into @name, @isscalarfunction  ")
                    .Append("end ")
                    .Append("end ")
                    .Append("deallocate sp_cursor")
                End With
                SqlHelper.ExecuteNonQuery(UpgradeConnectionString, CommandType.Text, sbSql.ToString)
            Catch objException As SqlException
                SendExceptionToAdmin(objException)
                Exceptions = ExceptionString(objException, sbSql.ToString)
            End Try
            Return Exceptions
        End Function
        Overrides Function TestDatabaseConnection(ByVal builder As DbConnectionStringBuilder, ByVal Owner As String, ByVal Qualifier As String) As String
            Try
                Dim sqlBuilder As SqlConnectionStringBuilder = TryCast(builder, SqlConnectionStringBuilder)
                Dim connectionString As String = Null.NullString
                If Not sqlBuilder Is Nothing Then
                    connectionString = sqlBuilder.ToString()
                    Dim dr As IDataReader = Nothing
                    Try
                        dr = SqlHelper.ExecuteReader(connectionString, String.Concat(Owner, Qualifier, "GetDatabaseVersion"))
                    Catch ex As SqlException
                        SendExceptionToAdmin(ex)
                        Dim message As String = "ERROR:"
                        Dim bError As Boolean = True
                        Dim i As Integer
                        Dim errorMessages As New StringBuilder()
                        For i = 0 To ex.Errors.Count - 1
                            Dim sqlError As SqlError = ex.Errors(i)
                            If sqlError.Number = 2812 And sqlError.Class = 16 Then
                                bError = False
                                Exit For
                            Else
                                With errorMessages
                                    .Append("Index #: ")
                                    .Append(i.ToString())
                                    .Append("
Source: ")
                                    .Append(sqlError.Source)
                                    .Append("
Class: ")
                                    .Append(sqlError.Class)
                                    .Append("
Number: ")
                                    .Append(sqlError.Number)
                                    .Append("
Message: ")
                                    .Append(sqlError.Message)
                                    .Append("

")
                                End With
                            End If
                        Next i
                        If bError Then
                            connectionString = String.Concat(message, errorMessages.ToString())
                        End If
                    Finally
                        If Not dr Is Nothing Then
                            dr.Close()
                        End If
                    End Try
                Else
                    'Invalid DbConnectionStringBuilder
                End If
                Return connectionString
            Catch ex As Exception
                SendExceptionToAdmin(ex)
                Return String.Empty
            End Try
        End Function
        Overrides Sub UpgradeDatabaseSchema(ByVal Major As Integer, ByVal Minor As Integer, ByVal Build As Integer)
            ' not necessary for SQL Server - use Transact-SQL scripts
        End Sub
        Public Overrides Sub UpdateDatabaseVersion(ByVal Major As Integer, ByVal Minor As Integer, ByVal Build As Integer)
            SqlHelper.ExecuteNonQuery(UpgradeConnectionString, QueryName("UpdateDatabaseVersion"), Major, Minor, Build)
        End Sub
#End Region

        ' host
        Overrides Function GetHostSettings() As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetHostSettings")), IDataReader)
        End Function
        Overrides Function GetHostSetting(ByVal SettingName As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetHostSetting"), SettingName), IDataReader)
        End Function
        Overrides Sub AddHostSetting(ByVal SettingName As String, ByVal SettingValue As String, ByVal SettingIsSecure As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddHostSetting"), SettingName, SettingValue, SettingIsSecure)
        End Sub
        Overrides Sub UpdateHostSetting(ByVal SettingName As String, ByVal SettingValue As String, ByVal SettingIsSecure As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateHostSetting"), SettingName, SettingValue, SettingIsSecure)
        End Sub
        ' portal
        Overrides Function AddPortalInfo(ByVal PortalName As String, ByVal Currency As String, ByVal FirstName As String, ByVal LastName As String, ByVal Username As String, ByVal Password As String, ByVal Email As String, ByVal ExpiryDate As Date, ByVal HostFee As Double, ByVal HostSpace As Double, ByVal PageQuota As Integer, ByVal UserQuota As Integer, ByVal SiteLogHistory As Integer, ByVal HomeDirectory As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddPortalInfo"), PortalName, Currency, GetNull(ExpiryDate), HostFee, HostSpace, PageQuota, UserQuota, GetNull(SiteLogHistory), HomeDirectory), Integer)
        End Function
        Overrides Function CreatePortal(ByVal PortalName As String, ByVal Currency As String, ByVal ExpiryDate As Date, ByVal HostFee As Double, ByVal HostSpace As Double, ByVal PageQuota As Integer, ByVal UserQuota As Integer, ByVal SiteLogHistory As Integer, ByVal HomeDirectory As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddPortalInfo"), PortalName, Currency, GetNull(ExpiryDate), HostFee, HostSpace, PageQuota, UserQuota, GetNull(SiteLogHistory), HomeDirectory), Integer)
        End Function
        Overrides Sub DeletePortalInfo(ByVal PortalId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeletePortalInfo"), PortalId)
        End Sub
        Overrides Function GetExpiredPortals() As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetExpiredPortals")), IDataReader)
        End Function
        Overrides Function GetPortal(ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortal"), PortalId), IDataReader)
        End Function
        Overrides Function GetPortalByAlias(ByVal PortalAlias As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortalByAlias"), PortalAlias), IDataReader)
        End Function
        Overrides Function GetPortalByTab(ByVal TabId As Integer, ByVal PortalAlias As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortalByTab"), TabId, PortalAlias), IDataReader)
        End Function
        Overrides Function GetPortalCount() As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("GetPortalCount")), Integer)
        End Function
        Overrides Function GetPortals() As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortals")), IDataReader)
        End Function
        Overrides Function GetPortalsByName(ByVal nameToMatch As String, ByVal pageIndex As Integer, ByVal pageSize As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortalsByName"), nameToMatch, pageIndex, pageSize), IDataReader)
        End Function
        Overrides Function GetPortalSpaceUsed(ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortalSpaceUsed"), GetNull(PortalId)), IDataReader)
        End Function
        Overrides Sub UpdatePortalInfo(ByVal PortalId As Integer, ByVal PortalName As String, ByVal LogoFile As String, ByVal FooterText As String, ByVal ExpiryDate As Date, ByVal UserRegistration As Integer, ByVal BannerAdvertising As Integer, ByVal Currency As String, ByVal AdministratorId As Integer, ByVal HostFee As Double, ByVal HostSpace As Double, ByVal PageQuota As Integer, ByVal UserQuota As Integer, ByVal PaymentProcessor As String, ByVal ProcessorUserId As String, ByVal ProcessorPassword As String, ByVal Description As String, ByVal KeyWords As String, ByVal BackgroundFile As String, ByVal SiteLogHistory As Integer, ByVal SplashTabId As Integer, ByVal HomeTabId As Integer, ByVal LoginTabId As Integer, ByVal UserTabId As Integer, ByVal DefaultLanguage As String, ByVal TimeZoneOffset As Integer, ByVal HomeDirectory As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdatePortalInfo"), PortalId, PortalName, GetNull(LogoFile), GetNull(FooterText), GetNull(ExpiryDate), UserRegistration, BannerAdvertising, Currency, GetNull(AdministratorId), HostFee, HostSpace, PageQuota, UserQuota, GetNull(PaymentProcessor), GetNull(ProcessorUserId), GetNull(ProcessorPassword), GetNull(Description), GetNull(KeyWords), GetNull(BackgroundFile), GetNull(SiteLogHistory), GetNull(SplashTabId), GetNull(HomeTabId), GetNull(LoginTabId), GetNull(UserTabId), GetNull(DefaultLanguage), GetNull(TimeZoneOffset), HomeDirectory)
        End Sub
        Overrides Sub UpdatePortalSetup(ByVal PortalId As Integer, ByVal AdministratorId As Integer, ByVal AdministratorRoleId As Integer, ByVal RegisteredRoleId As Integer, ByVal SplashTabId As Integer, ByVal HomeTabId As Integer, ByVal LoginTabId As Integer, ByVal UserTabId As Integer, ByVal AdminTabId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdatePortalSetup"), PortalId, AdministratorId, AdministratorRoleId, RegisteredRoleId, SplashTabId, HomeTabId, LoginTabId, UserTabId, AdminTabId)
        End Sub
        Overrides Function VerifyPortal(ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("VerifyPortal"), PortalId), IDataReader)
        End Function
        Overrides Function VerifyPortalTab(ByVal PortalId As Integer, ByVal TabId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("VerifyPortalTab"), PortalId, TabId), IDataReader)
        End Function
        ' tab
        Overloads Overrides Function AddTab(ByVal PortalId As Integer, ByVal TabName As String, ByVal IsVisible As Boolean, ByVal DisableLink As Boolean, ByVal ParentId As Integer, ByVal IconFile As String, ByVal Title As String, ByVal Description As String, ByVal KeyWords As String, ByVal Url As String, ByVal SkinSrc As String, ByVal ContainerSrc As String, ByVal TabPath As String, ByVal StartDate As Date, ByVal EndDate As Date, ByVal RefreshInterval As Integer, ByVal PageHeadText As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddTab"), GetNull(PortalId), TabName, IsVisible, DisableLink, GetNull(ParentId), IconFile, Title, Description, KeyWords, Url, GetNull(SkinSrc), GetNull(ContainerSrc), TabPath, GetNull(StartDate), GetNull(EndDate), GetNull(RefreshInterval), GetNull(PageHeadText)), Integer)
        End Function
        _
         Overloads Overrides Sub UpdateTab(ByVal TabId As Integer, ByVal TabName As String, ByVal IsVisible As Boolean, ByVal DisableLink As Boolean, ByVal ParentId As Integer, ByVal IconFile As String, ByVal Title As String, ByVal Description As String, ByVal KeyWords As String, ByVal IsDeleted As Boolean, ByVal Url As String, ByVal SkinSrc As String, ByVal ContainerSrc As String, ByVal TabPath As String, ByVal StartDate As Date, ByVal EndDate As Date)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateTab"), TabId, TabName, IsVisible, DisableLink, GetNull(ParentId), IconFile, Title, Description, KeyWords, IsDeleted, Url, GetNull(SkinSrc), GetNull(ContainerSrc), TabPath, GetNull(StartDate), GetNull(EndDate))
        End Sub
        Overloads Overrides Sub UpdateTab(ByVal TabId As Integer, ByVal TabName As String, ByVal IsVisible As Boolean, ByVal DisableLink As Boolean, ByVal ParentId As Integer, ByVal IconFile As String, ByVal Title As String, ByVal Description As String, ByVal KeyWords As String, ByVal IsDeleted As Boolean, ByVal Url As String, ByVal SkinSrc As String, ByVal ContainerSrc As String, ByVal TabPath As String, ByVal StartDate As Date, ByVal EndDate As Date, ByVal RefreshInterval As Integer, ByVal PageHeadText As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateTab"), TabId, TabName, IsVisible, DisableLink, GetNull(ParentId), IconFile, Title, Description, KeyWords, IsDeleted, Url, GetNull(SkinSrc), GetNull(ContainerSrc), TabPath, GetNull(StartDate), GetNull(EndDate), GetNull(RefreshInterval), GetNull(PageHeadText))
        End Sub
        Overrides Sub UpdateTabOrder(ByVal TabId As Integer, ByVal TabOrder As Integer, ByVal Level As Integer, ByVal ParentId As Integer, ByVal TabPath As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateTabOrder"), TabId, TabOrder, Level, GetNull(ParentId), TabPath)
        End Sub
        Overrides Sub DeleteTab(ByVal TabId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteTab"), TabId)
        End Sub
        Overrides Function GetTabs(ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabs"), GetNull(PortalId)), IDataReader)
        End Function
        Overrides Function GetAllTabs() As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetAllTabs")), IDataReader)
        End Function
        Overrides Function GetTab(ByVal TabId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTab"), TabId), IDataReader)
        End Function
        Overrides Function GetTabByName(ByVal TabName As String, ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabByName"), TabName, GetNull(PortalId)), IDataReader)
        End Function
        Overrides Function GetTabCount(ByVal PortalId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("GetTabCount"), PortalId), Integer)
        End Function
        Overrides Function GetTabsByParentId(ByVal ParentId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabsByParentId"), ParentId), IDataReader)
        End Function
        Overrides Function GetTabPanes(ByVal TabId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabPanes"), TabId), IDataReader)
        End Function
        Overrides Function GetPortalTabModules(ByVal PortalId As Integer, ByVal TabId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabModules"), TabId), IDataReader)
        End Function
        Overrides Function GetTabModules(ByVal TabId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabModules"), TabId), IDataReader)
        End Function
        ' module
        Overrides Function GetAllModules() As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetAllModules")), IDataReader)
        End Function
        Overrides Function GetModules(ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModules"), PortalId), IDataReader)
        End Function
        Overrides Function GetAllTabsModules(ByVal PortalId As Integer, ByVal AllTabs As Boolean) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetAllTabsModules"), PortalId, AllTabs), IDataReader)
        End Function
        Overrides Function GetModule(ByVal ModuleId As Integer, ByVal TabId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModule"), ModuleId, GetNull(TabId)), IDataReader)
        End Function
        Overrides Function GetModuleByDefinition(ByVal PortalId As Integer, ByVal FriendlyName As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModuleByDefinition"), GetNull(PortalId), FriendlyName), IDataReader)
        End Function
        Overrides Function AddModule(ByVal PortalID As Integer, ByVal ModuleDefID As Integer, ByVal ModuleTitle As String, ByVal AllTabs As Boolean, ByVal Header As String, ByVal Footer As String, ByVal StartDate As DateTime, ByVal EndDate As DateTime, ByVal InheritViewPermissions As Boolean, ByVal IsDeleted As Boolean) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddModule"), GetNull(PortalID), ModuleDefID, ModuleTitle, AllTabs, GetNull(Header), GetNull(Footer), GetNull(StartDate), GetNull(EndDate), InheritViewPermissions, IsDeleted), Integer)
        End Function
        Overrides Sub UpdateModule(ByVal ModuleId As Integer, ByVal ModuleTitle As String, ByVal AllTabs As Boolean, ByVal Header As String, ByVal Footer As String, ByVal StartDate As DateTime, ByVal EndDate As DateTime, ByVal InheritViewPermissions As Boolean, ByVal IsDeleted As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateModule"), ModuleId, ModuleTitle, AllTabs, GetNull(Header), GetNull(Footer), GetNull(StartDate), GetNull(EndDate), InheritViewPermissions, IsDeleted)
        End Sub
        Overrides Sub DeleteModule(ByVal ModuleId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteModule"), ModuleId)
        End Sub
        Overrides Function GetTabModuleOrder(ByVal TabId As Integer, ByVal PaneName As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabModuleOrder"), TabId, PaneName), IDataReader)
        End Function
        Overrides Sub UpdateModuleOrder(ByVal TabId As Integer, ByVal ModuleId As Integer, ByVal ModuleOrder As Integer, ByVal PaneName As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateModuleOrder"), TabId, ModuleId, ModuleOrder, PaneName)
        End Sub
        Overrides Sub AddTabModule(ByVal TabId As Integer, ByVal ModuleId As Integer, ByVal ModuleOrder As Integer, ByVal PaneName As String, ByVal CacheTime As Integer, ByVal Alignment As String, ByVal Color As String, ByVal Border As String, ByVal IconFile As String, ByVal Visibility As Integer, ByVal ContainerSrc As String, ByVal DisplayTitle As Boolean, ByVal DisplayPrint As Boolean, ByVal DisplaySyndicate As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddTabModule"), TabId, ModuleId, ModuleOrder, PaneName, CacheTime, GetNull(Alignment), GetNull(Color), GetNull(Border), GetNull(IconFile), Visibility, GetNull(ContainerSrc), DisplayTitle, DisplayPrint, DisplaySyndicate)
        End Sub
        Overrides Sub UpdateTabModule(ByVal TabId As Integer, ByVal ModuleId As Integer, ByVal ModuleOrder As Integer, ByVal PaneName As String, ByVal CacheTime As Integer, ByVal Alignment As String, ByVal Color As String, ByVal Border As String, ByVal IconFile As String, ByVal Visibility As Integer, ByVal ContainerSrc As String, ByVal DisplayTitle As Boolean, ByVal DisplayPrint As Boolean, ByVal DisplaySyndicate As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateTabModule"), TabId, ModuleId, ModuleOrder, PaneName, CacheTime, GetNull(Alignment), GetNull(Color), GetNull(Border), GetNull(IconFile), Visibility, GetNull(ContainerSrc), DisplayTitle, DisplayPrint, DisplaySyndicate)
        End Sub
        Overrides Sub DeleteTabModule(ByVal TabId As Integer, ByVal ModuleId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteTabModule"), TabId, ModuleId)
        End Sub
        Overrides Function GetSearchModules(ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSearchModules"), PortalId), IDataReader)
        End Function
        Overrides Function GetModuleSettings(ByVal ModuleId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModuleSettings"), ModuleId), IDataReader)
        End Function
        Overrides Function GetModuleSetting(ByVal ModuleId As Integer, ByVal SettingName As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModuleSetting"), ModuleId, SettingName), IDataReader)
        End Function
        Overrides Sub AddModuleSetting(ByVal ModuleId As Integer, ByVal SettingName As String, ByVal SettingValue As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddModuleSetting"), ModuleId, SettingName, SettingValue)
        End Sub
        Overrides Sub UpdateModuleSetting(ByVal ModuleId As Integer, ByVal SettingName As String, ByVal SettingValue As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateModuleSetting"), ModuleId, SettingName, SettingValue)
        End Sub
        Overrides Sub DeleteModuleSetting(ByVal ModuleId As Integer, ByVal SettingName As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteModuleSetting"), ModuleId, SettingName)
        End Sub
        Overrides Sub DeleteModuleSettings(ByVal ModuleId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteModuleSettings"), ModuleId)
        End Sub
        Overrides Function GetTabModuleSettings(ByVal TabModuleId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabModuleSettings"), TabModuleId), IDataReader)
        End Function
        Overrides Function GetTabModuleSetting(ByVal TabModuleId As Integer, ByVal SettingName As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabModuleSetting"), TabModuleId, SettingName), IDataReader)
        End Function
        Overrides Sub AddTabModuleSetting(ByVal TabModuleId As Integer, ByVal SettingName As String, ByVal SettingValue As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddTabModuleSetting"), TabModuleId, SettingName, SettingValue)
        End Sub
        Overrides Sub UpdateTabModuleSetting(ByVal TabModuleId As Integer, ByVal SettingName As String, ByVal SettingValue As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateTabModuleSetting"), TabModuleId, SettingName, SettingValue)
        End Sub
        Overrides Sub DeleteTabModuleSetting(ByVal TabModuleId As Integer, ByVal SettingName As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteTabModuleSetting"), TabModuleId, SettingName)
        End Sub
        Overrides Sub DeleteTabModuleSettings(ByVal TabModuleId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteTabModuleSettings"), TabModuleId)
        End Sub
        ' module definition
        Overrides Function GetDesktopModule(ByVal DesktopModuleId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetDesktopModule"), DesktopModuleId), IDataReader)
        End Function
        Overrides Function GetDesktopModuleByFriendlyName(ByVal FriendlyName As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetDesktopModuleByFriendlyName"), FriendlyName), IDataReader)
        End Function
        Overrides Function GetDesktopModuleByModuleName(ByVal ModuleName As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetDesktopModuleByModuleName"), ModuleName), IDataReader)
        End Function
        Overrides Function GetDesktopModules() As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetDesktopModules")), IDataReader)
        End Function
        Overrides Function GetDesktopModulesByPortal(ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetDesktopModulesByPortal"), PortalId), IDataReader)
        End Function
        Overrides Function AddDesktopModule(ByVal ModuleName As String, ByVal FolderName As String, ByVal FriendlyName As String, ByVal Description As String, ByVal Version As String, ByVal IsPremium As Boolean, ByVal IsAdmin As Boolean, ByVal BusinessControllerClass As String, ByVal SupportedFeatures As Integer, ByVal CompatibleVersions As String, ByVal Dependencies As String, ByVal Permissions As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddDesktopModule"), ModuleName, FolderName, FriendlyName, GetNull(Description), GetNull(Version), IsPremium, IsAdmin, BusinessControllerClass, SupportedFeatures, GetNull(CompatibleVersions), GetNull(Dependencies), GetNull(Permissions)), Integer)
        End Function
        Overrides Sub UpdateDesktopModule(ByVal DesktopModuleId As Integer, ByVal ModuleName As String, ByVal FolderName As String, ByVal FriendlyName As String, ByVal Description As String, ByVal Version As String, ByVal IsPremium As Boolean, ByVal IsAdmin As Boolean, ByVal BusinessControllerClass As String, ByVal SupportedFeatures As Integer, ByVal CompatibleVersions As String, ByVal Dependencies As String, ByVal Permissions As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateDesktopModule"), DesktopModuleId, ModuleName, FolderName, FriendlyName, GetNull(Description), GetNull(Version), IsPremium, IsAdmin, BusinessControllerClass, SupportedFeatures, GetNull(CompatibleVersions), GetNull(Dependencies), GetNull(Permissions))
        End Sub
        Overrides Sub DeleteDesktopModule(ByVal DesktopModuleId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteDesktopModule"), DesktopModuleId)
        End Sub
        Overrides Function GetPortalDesktopModules(ByVal PortalId As Integer, ByVal DesktopModuleId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortalDesktopModules"), GetNull(PortalId), GetNull(DesktopModuleId)), IDataReader)
        End Function
        Overrides Function AddPortalDesktopModule(ByVal PortalId As Integer, ByVal DesktopModuleId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddPortalDesktopModule"), PortalId, DesktopModuleId), Integer)
        End Function
        Overrides Sub DeletePortalDesktopModules(ByVal PortalId As Integer, ByVal DesktopModuleId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeletePortalDesktopModules"), GetNull(PortalId), GetNull(DesktopModuleId))
        End Sub
        Overrides Function GetModuleDefinitions(ByVal DesktopModuleId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModuleDefinitions"), DesktopModuleId), IDataReader)
        End Function
        Overrides Function GetModuleDefinition(ByVal ModuleDefId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModuleDefinition"), ModuleDefId), IDataReader)
        End Function
        Overrides Function GetModuleDefinitionByName(ByVal DesktopModuleId As Integer, ByVal FriendlyName As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModuleDefinitionByName"), DesktopModuleId, FriendlyName), IDataReader)
        End Function
        Overrides Function AddModuleDefinition(ByVal DesktopModuleId As Integer, ByVal FriendlyName As String, ByVal DefaultCacheTime As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddModuleDefinition"), DesktopModuleId, FriendlyName, DefaultCacheTime), Integer)
        End Function
        Overrides Sub DeleteModuleDefinition(ByVal ModuleDefId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteModuleDefinition"), ModuleDefId)
        End Sub
        Overrides Sub UpdateModuleDefinition(ByVal ModuleDefId As Integer, ByVal FriendlyName As String, ByVal DefaultCacheTime As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateModuleDefinition"), ModuleDefId, FriendlyName, DefaultCacheTime)
        End Sub
        Overrides Function GetModuleControl(ByVal ModuleControlId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModuleControl"), ModuleControlId), IDataReader)
        End Function
        Overrides Function GetModuleControls(ByVal ModuleDefId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModuleControls"), GetNull(ModuleDefId)), IDataReader)
        End Function
        Overrides Function GetModuleControlsByKey(ByVal ControlKey As String, ByVal ModuleDefId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModuleControlsByKey"), GetNull(ControlKey), GetNull(ModuleDefId)), IDataReader)
        End Function
        Overrides Function GetModuleControlByKeyAndSrc(ByVal ModuleDefID As Integer, ByVal ControlKey As String, ByVal ControlSrc As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModuleControlByKeyAndSrc"), GetNull(ModuleDefID), GetNull(ControlKey), GetNull(ControlSrc)), IDataReader)
        End Function
        Overrides Function AddModuleControl(ByVal ModuleDefId As Integer, ByVal ControlKey As String, ByVal ControlTitle As String, ByVal ControlSrc As String, ByVal IconFile As String, ByVal ControlType As Integer, ByVal ViewOrder As Integer, ByVal HelpUrl As String, ByVal SupportsPartialRendering As Boolean) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddModuleControl"), GetNull(ModuleDefId), GetNull(ControlKey), GetNull(ControlTitle), ControlSrc, GetNull(IconFile), ControlType, GetNull(ViewOrder), GetNull(HelpUrl), SupportsPartialRendering), Integer)
        End Function
        Overrides Sub UpdateModuleControl(ByVal ModuleControlId As Integer, ByVal ModuleDefId As Integer, ByVal ControlKey As String, ByVal ControlTitle As String, ByVal ControlSrc As String, ByVal IconFile As String, ByVal ControlType As Integer, ByVal ViewOrder As Integer, ByVal HelpUrl As String, ByVal SupportsPartialRendering As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateModuleControl"), ModuleControlId, GetNull(ModuleDefId), GetNull(ControlKey), GetNull(ControlTitle), ControlSrc, GetNull(IconFile), ControlType, GetNull(ViewOrder), GetNull(HelpUrl), SupportsPartialRendering)
        End Sub
        Overrides Sub DeleteModuleControl(ByVal ModuleControlId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteModuleControl"), ModuleControlId)
        End Sub
        ' files
        Overrides Function GetFiles(ByVal PortalId As Integer, ByVal FolderID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetFiles"), GetNull(PortalId), FolderID), IDataReader)
        End Function
        Overrides Function GetFile(ByVal FileName As String, ByVal PortalId As Integer, ByVal FolderID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetFile"), FileName, GetNull(PortalId), FolderID), IDataReader)
        End Function
        Overrides Function GetFileById(ByVal FileId As Integer, ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetFileById"), FileId, GetNull(PortalId)), IDataReader)
        End Function
        Overrides Sub DeleteFile(ByVal PortalId As Integer, ByVal FileName As String, ByVal FolderID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteFile"), GetNull(PortalId), FileName, FolderID)
        End Sub
        Overrides Sub DeleteFiles(ByVal PortalId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteFiles"), GetNull(PortalId))
        End Sub
        Overrides Function AddFile(ByVal PortalId As Integer, ByVal FileName As String, ByVal Extension As String, ByVal Size As Long, ByVal Width As Integer, ByVal Height As Integer, ByVal ContentType As String, ByVal Folder As String, ByVal FolderID As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddFile"), GetNull(PortalId), FileName, Extension, Size, GetNull(Width), GetNull(Height), ContentType, Folder, FolderID), Integer)
        End Function
        Overrides Sub UpdateFile(ByVal FileId As Integer, ByVal FileName As String, ByVal Extension As String, ByVal Size As Long, ByVal Width As Integer, ByVal Height As Integer, ByVal ContentType As String, ByVal Folder As String, ByVal FolderID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateFile"), FileId, FileName, Extension, Size, GetNull(Width), GetNull(Height), ContentType, Folder, FolderID)
        End Sub
        Overrides Function GetAllFiles() As DataTable
            Return SqlHelper.ExecuteDataset(ConnectionString, QueryName("GetAllFiles")).Tables(0)
        End Function
        Overrides Function GetFileContent(ByVal FileId As Integer, ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetFileContent"), FileId, GetNull(PortalId)), IDataReader)
        End Function
        Overrides Sub UpdateFileContent(ByVal FileId As Integer, ByVal Content() As Byte)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateFileContent"), FileId, GetNull(Content))
        End Sub
        ' site log
        Overrides Sub AddSiteLog(ByVal DateTime As Date, ByVal PortalId As Integer, ByVal UserId As Integer, ByVal Referrer As String, ByVal URL As String, ByVal UserAgent As String, ByVal UserHostAddress As String, ByVal UserHostName As String, ByVal TabId As Integer, ByVal AffiliateId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddSiteLog"), DateTime, PortalId, GetNull(UserId), GetNull(Referrer), GetNull(URL), GetNull(UserAgent), GetNull(UserHostAddress), GetNull(UserHostName), GetNull(TabId), GetNull(AffiliateId))
        End Sub
        Overrides Function GetSiteLog(ByVal PortalId As Integer, ByVal PortalAlias As String, ByVal ReportName As String, ByVal StartDate As Date, ByVal EndDate As Date) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName(ReportName), PortalId, PortalAlias, StartDate, EndDate), IDataReader)
        End Function
        Overrides Function GetSiteLogReports() As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSiteLogReports")), IDataReader)
        End Function
        Overrides Sub DeleteSiteLog(ByVal DateTime As Date, ByVal PortalId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteSiteLog"), DateTime, PortalId)
        End Sub
        ' database
        Overrides Function GetTables() As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTables")), IDataReader)
        End Function
        Overrides Function GetFields(ByVal TableName As String) As IDataReader
            Dim strSql As String = String.Concat("SELECT * FROM {objectQualifier}", TableName, " WHERE 1 = 0")
            Return ExecuteSql(strSql)
        End Function
        ' vendors
        Overrides Function GetVendors(ByVal PortalId As Integer, ByVal UnAuthorized As Boolean, ByVal PageIndex As Integer, ByVal PageSize As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetVendors"), GetNull(PortalId), UnAuthorized, GetNull(PageSize), GetNull(PageIndex)), IDataReader)
        End Function
        Overrides Function GetVendorsByEmail(ByVal Filter As String, ByVal PortalId As Integer, ByVal PageIndex As Integer, ByVal PageSize As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetVendorsByEmail"), Filter, GetNull(PortalId), GetNull(PageSize), GetNull(PageIndex)), IDataReader)
        End Function
        Overrides Function GetVendorsByName(ByVal Filter As String, ByVal PortalId As Integer, ByVal PageIndex As Integer, ByVal PageSize As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetVendorsByName"), Filter, GetNull(PortalId), GetNull(PageSize), GetNull(PageIndex)), IDataReader)
        End Function
        Overrides Function GetVendor(ByVal VendorId As Integer, ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetVendor"), VendorId, GetNull(PortalId)), IDataReader)
        End Function
        Overrides Sub DeleteVendor(ByVal VendorId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteVendor"), VendorId)
        End Sub
        Overrides Function AddVendor(ByVal PortalId As Integer, ByVal VendorName As String, ByVal Unit As String, ByVal Street As String, ByVal City As String, ByVal Region As String, ByVal Country As String, ByVal PostalCode As String, ByVal Telephone As String, ByVal Fax As String, ByVal Cell As String, ByVal Email As String, ByVal Website As String, ByVal FirstName As String, ByVal LastName As String, ByVal UserName As String, ByVal LogoFile As String, ByVal KeyWords As String, ByVal Authorized As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddVendor"), GetNull(PortalId), VendorName, Unit, Street, City, Region, Country, PostalCode, Telephone, Fax, Cell, Email, Website, FirstName, LastName, UserName, LogoFile, KeyWords, Boolean.Parse(Authorized)), Integer)
        End Function
        Overrides Sub UpdateVendor(ByVal VendorId As Integer, ByVal VendorName As String, ByVal Unit As String, ByVal Street As String, ByVal City As String, ByVal Region As String, ByVal Country As String, ByVal PostalCode As String, ByVal Telephone As String, ByVal Fax As String, ByVal Cell As String, ByVal Email As String, ByVal Website As String, ByVal FirstName As String, ByVal LastName As String, ByVal UserName As String, ByVal LogoFile As String, ByVal KeyWords As String, ByVal Authorized As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateVendor"), VendorId, VendorName, Unit, Street, City, Region, Country, PostalCode, Telephone, Fax, Cell, Email, Website, FirstName, LastName, UserName, LogoFile, KeyWords, Boolean.Parse(Authorized))
        End Sub
        Overrides Function GetVendorClassifications(ByVal VendorId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetVendorClassifications"), GetNull(VendorId)), IDataReader)
        End Function
        Overrides Sub DeleteVendorClassifications(ByVal VendorId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteVendorClassifications"), VendorId)
        End Sub
        Overrides Function AddVendorClassification(ByVal VendorId As Integer, ByVal ClassificationId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddVendorClassification"), VendorId, ClassificationId), Integer)
        End Function
        ' banners
        Overrides Function GetBanners(ByVal VendorId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetBanners"), VendorId), IDataReader)
        End Function
        Overrides Function GetBanner(ByVal BannerId As Integer, ByVal VendorId As Integer, ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetBanner"), BannerId, VendorId, GetNull(PortalId)), IDataReader)
        End Function
        Overrides Function GetBannerGroups(ByVal PortalId As Integer) As DataTable
            Return SqlHelper.ExecuteDataset(ConnectionString, QueryName("GetBannerGroups"), GetNull(PortalId)).Tables(0)
        End Function
        Overrides Sub DeleteBanner(ByVal BannerId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteBanner"), BannerId)
        End Sub
        Overrides Function AddBanner(ByVal BannerName As String, ByVal VendorId As Integer, ByVal ImageFile As String, ByVal URL As String, ByVal Impressions As Integer, ByVal CPM As Double, ByVal StartDate As Date, ByVal EndDate As Date, ByVal UserName As String, ByVal BannerTypeId As Integer, ByVal Description As String, ByVal GroupName As String, ByVal Criteria As Integer, ByVal Width As Integer, ByVal Height As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddBanner"), BannerName, VendorId, GetNull(ImageFile), GetNull(URL), Impressions, CPM, GetNull(StartDate), GetNull(EndDate), UserName, BannerTypeId, GetNull(Description), GetNull(GroupName), Criteria, Width, Height), Integer)
        End Function
        Overrides Sub UpdateBanner(ByVal BannerId As Integer, ByVal BannerName As String, ByVal ImageFile As String, ByVal URL As String, ByVal Impressions As Integer, ByVal CPM As Double, ByVal StartDate As Date, ByVal EndDate As Date, ByVal UserName As String, ByVal BannerTypeId As Integer, ByVal Description As String, ByVal GroupName As String, ByVal Criteria As Integer, ByVal Width As Integer, ByVal Height As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateBanner"), BannerId, BannerName, GetNull(ImageFile), GetNull(URL), Impressions, CPM, GetNull(StartDate), GetNull(EndDate), UserName, BannerTypeId, GetNull(Description), GetNull(GroupName), Criteria, Width, Height)
        End Sub
        Overrides Function FindBanners(ByVal PortalId As Integer, ByVal BannerTypeId As Integer, ByVal GroupName As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("FindBanners"), GetNull(PortalId), GetNull(BannerTypeId), GetNull(GroupName)), IDataReader)
        End Function
        Overrides Sub UpdateBannerViews(ByVal BannerId As Integer, ByVal StartDate As Date, ByVal EndDate As Date)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateBannerViews"), BannerId, GetNull(StartDate), GetNull(EndDate))
        End Sub
        Overrides Sub UpdateBannerClickThrough(ByVal BannerId As Integer, ByVal VendorId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateBannerClickThrough"), BannerId, VendorId)
        End Sub
        ' affiliates
        Overrides Function GetAffiliates(ByVal VendorId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetAffiliates"), VendorId), IDataReader)
        End Function
        Overrides Function GetAffiliate(ByVal AffiliateId As Integer, ByVal VendorId As Integer, ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetAffiliate"), AffiliateId, VendorId, GetNull(PortalId)), IDataReader)
        End Function
        Overrides Sub DeleteAffiliate(ByVal AffiliateId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteAffiliate"), AffiliateId)
        End Sub
        Overrides Function AddAffiliate(ByVal VendorId As Integer, ByVal StartDate As Date, ByVal EndDate As Date, ByVal CPC As Double, ByVal CPA As Double) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddAffiliate"), VendorId, GetNull(StartDate), GetNull(EndDate), CPC, CPA), Integer)
        End Function
        Overrides Sub UpdateAffiliate(ByVal AffiliateId As Integer, ByVal StartDate As Date, ByVal EndDate As Date, ByVal CPC As Double, ByVal CPA As Double)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateAffiliate"), AffiliateId, GetNull(StartDate), GetNull(EndDate), CPC, CPA)
        End Sub
        Overrides Sub UpdateAffiliateStats(ByVal AffiliateId As Integer, ByVal Clicks As Integer, ByVal Acquisitions As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateAffiliateStats"), AffiliateId, Clicks, Acquisitions)
        End Sub
        ' skins/containers
        Overrides Function GetSkin(ByVal SkinRoot As String, ByVal PortalId As Integer, ByVal SkinType As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSkin"), SkinRoot, GetNull(PortalId), SkinType), IDataReader)
        End Function
        Overrides Function GetSkins(ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSkins"), GetNull(PortalId)), IDataReader)
        End Function
        Overrides Sub DeleteSkin(ByVal SkinRoot As String, ByVal PortalId As Integer, ByVal SkinType As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteSkin"), SkinRoot, GetNull(PortalId), SkinType)
        End Sub
        Overrides Function AddSkin(ByVal SkinRoot As String, ByVal PortalId As Integer, ByVal SkinType As Integer, ByVal SkinSrc As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddSkin"), SkinRoot, GetNull(PortalId), SkinType, SkinSrc), Integer)
        End Function
        Overrides Function CanDeleteSkin(ByVal SkinType As String, ByVal SkinFoldername As String) As Boolean
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("CanDeleteSkin"), SkinType, SkinFoldername), Boolean)
        End Function
        ' personalization
        Overrides Function GetAllProfiles() As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetAllProfiles")), IDataReader)
        End Function
        Overrides Function GetProfile(ByVal UserId As Integer, ByVal PortalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetProfile"), UserId, PortalId), IDataReader)
        End Function
        Overrides Sub AddProfile(ByVal UserId As Integer, ByVal PortalId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddProfile"), UserId, PortalId)
        End Sub
        Overrides Sub UpdateProfile(ByVal UserId As Integer, ByVal PortalId As Integer, ByVal ProfileData As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateProfile"), UserId, PortalId, ProfileData)
        End Sub
        'profile property definitions
        Overrides Function AddPropertyDefinition(ByVal PortalId As Integer, ByVal ModuleDefId As Integer, ByVal DataType As Integer, ByVal DefaultValue As String, ByVal PropertyCategory As String, ByVal PropertyName As String, ByVal Required As Boolean, ByVal ValidationExpression As String, ByVal ViewOrder As Integer, ByVal Visible As Boolean, ByVal Length As Integer) As Integer
            Dim retValue As Integer = Null.NullInteger
            Try
                retValue = CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddPropertyDefinition"), _
                    GetNull(PortalId), ModuleDefId, DataType, DefaultValue, PropertyCategory, _
                    PropertyName, Required, ValidationExpression, ViewOrder, Visible, Length), Integer)
            Catch ex As SqlException
                'If not a duplicate (throw an Exception)
                retValue = -ex.Number
                If ex.Number <> 2601 Then
                    Throw ex
                End If
            End Try
            Return retValue
        End Function
        Overrides Sub DeletePropertyDefinition(ByVal definitionId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeletePropertyDefinition"), definitionId)
        End Sub
        Overrides Function GetPropertyDefinition(ByVal definitionId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPropertyDefinition"), definitionId), IDataReader)
        End Function
        Overrides Function GetPropertyDefinitionByName(ByVal portalId As Integer, ByVal name As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPropertyDefinitionByName"), GetNull(portalId), name), IDataReader)
        End Function
        Overrides Function GetPropertyDefinitionsByPortal(ByVal portalId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPropertyDefinitionsByPortal"), GetNull(portalId)), IDataReader)
        End Function
        Overrides Sub UpdatePropertyDefinition(ByVal PropertyDefinitionId As Integer, ByVal DataType As Integer, ByVal DefaultValue As String, ByVal PropertyCategory As String, ByVal PropertyName As String, ByVal Required As Boolean, ByVal ValidationExpression As String, ByVal ViewOrder As Integer, ByVal Visible As Boolean, ByVal Length As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdatePropertyDefinition"), _
                PropertyDefinitionId, DataType, DefaultValue, PropertyCategory, _
                PropertyName, Required, ValidationExpression, ViewOrder, Visible, Length)
        End Sub
        ' urls
        Overrides Function GetUrls(ByVal PortalID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetUrls"), PortalID), IDataReader)
        End Function
        Overrides Function GetUrl(ByVal PortalID As Integer, ByVal Url As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetUrl"), PortalID, Url), IDataReader)
        End Function
        Overrides Sub AddUrl(ByVal PortalID As Integer, ByVal Url As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddUrl"), PortalID, Url)
        End Sub
        Overrides Sub DeleteUrl(ByVal PortalID As Integer, ByVal Url As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteUrl"), PortalID, Url)
        End Sub
        Overrides Function GetUrlTracking(ByVal PortalID As Integer, ByVal Url As String, ByVal ModuleID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetUrlTracking"), PortalID, Url, GetNull(ModuleID)), IDataReader)
        End Function
        Overrides Sub AddUrlTracking(ByVal PortalID As Integer, ByVal Url As String, ByVal UrlType As String, ByVal LogActivity As Boolean, ByVal TrackClicks As Boolean, ByVal ModuleID As Integer, ByVal NewWindow As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddUrlTracking"), PortalID, Url, UrlType, LogActivity, TrackClicks, GetNull(ModuleID), NewWindow)
        End Sub
        Overrides Sub UpdateUrlTracking(ByVal PortalID As Integer, ByVal Url As String, ByVal LogActivity As Boolean, ByVal TrackClicks As Boolean, ByVal ModuleID As Integer, ByVal NewWindow As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateUrlTracking"), PortalID, Url, LogActivity, TrackClicks, GetNull(ModuleID), NewWindow)
        End Sub
        Overrides Sub DeleteUrlTracking(ByVal PortalID As Integer, ByVal Url As String, ByVal ModuleID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteUrlTracking"), PortalID, Url, GetNull(ModuleID))
        End Sub
        Overrides Sub UpdateUrlTrackingStats(ByVal PortalID As Integer, ByVal Url As String, ByVal ModuleID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateUrlTrackingStats"), PortalID, Url, GetNull(ModuleID))
        End Sub
        Overrides Function GetUrlLog(ByVal UrlTrackingID As Integer, ByVal StartDate As Date, ByVal EndDate As Date) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetUrlLog"), UrlTrackingID, GetNull(StartDate), GetNull(EndDate)), IDataReader)
        End Function
        Overrides Sub AddUrlLog(ByVal UrlTrackingID As Integer, ByVal UserID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddUrlLog"), UrlTrackingID, GetNull(UserID))
        End Sub
        'Permission
        Overrides Function GetPermissionsByModuleDefID(ByVal ModuleDefID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPermissionsByModuleDefID"), ModuleDefID), IDataReader)
        End Function
        Overrides Function GetPermissionsByModuleID(ByVal ModuleID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPermissionsByModuleID"), ModuleID), IDataReader)
        End Function
        Overrides Function GetPermissionsByFolderPath(ByVal PortalID As Integer, ByVal Folder As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPermissionsByFolderPath"), GetNull(PortalID), Folder), IDataReader)
        End Function
        Overrides Function GetPermissionByCodeAndKey(ByVal PermissionCode As String, ByVal PermissionKey As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPermissionByCodeAndKey"), GetNull(PermissionCode), GetNull(PermissionKey)), IDataReader)
        End Function
        Overrides Function GetPermissionsByTabID(ByVal TabID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPermissionsByTabID"), TabID), IDataReader)
        End Function
        Overrides Function GetPermission(ByVal permissionID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPermission"), permissionID), IDataReader)
        End Function
        Overrides Sub DeletePermission(ByVal permissionID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeletePermission"), permissionID)
        End Sub
        Overrides Function AddPermission(ByVal permissionCode As String, ByVal moduleDefID As Integer, ByVal permissionKey As String, ByVal permissionName As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddPermission"), moduleDefID, permissionCode, permissionKey, permissionName), Integer)
        End Function
        Overrides Sub UpdatePermission(ByVal permissionID As Integer, ByVal permissionCode As String, ByVal moduleDefID As Integer, ByVal permissionKey As String, ByVal permissionName As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdatePermission"), permissionID, permissionCode, moduleDefID, permissionKey, permissionName)
        End Sub
        'ModulePermission
        Overrides Function GetModulePermission(ByVal modulePermissionID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModulePermission"), modulePermissionID), IDataReader)
        End Function
        Overrides Function GetModulePermissionsByModuleID(ByVal moduleID As Integer, ByVal PermissionID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModulePermissionsByModuleID"), moduleID, PermissionID), IDataReader)
        End Function
        Overrides Function GetModulePermissionsByPortal(ByVal PortalID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModulePermissionsByPortal"), PortalID), IDataReader)
        End Function
        Overrides Function GetModulePermissionsByTabID(ByVal TabID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetModulePermissionsByTabID"), TabID), IDataReader)
        End Function
        Overrides Sub DeleteModulePermissionsByModuleID(ByVal ModuleID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteModulePermissionsByModuleID"), ModuleID)
        End Sub
        Overrides Sub DeleteModulePermission(ByVal modulePermissionID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteModulePermission"), modulePermissionID)
        End Sub
        Overrides Function AddModulePermission(ByVal moduleID As Integer, ByVal PermissionID As Integer, ByVal roleID As Integer, ByVal AllowAccess As Boolean, ByVal UserID As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddModulePermission"), moduleID, PermissionID, GetRoleNull(roleID), AllowAccess, GetNull(UserID)), Integer)
        End Function
        Overrides Sub UpdateModulePermission(ByVal modulePermissionID As Integer, ByVal moduleID As Integer, ByVal PermissionID As Integer, ByVal roleID As Integer, ByVal AllowAccess As Boolean, ByVal UserID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateModulePermission"), modulePermissionID, moduleID, PermissionID, GetRoleNull(roleID), AllowAccess, GetNull(UserID))
        End Sub

        'TabPermission
        Overrides Function GetTabPermissionsByPortal(ByVal PortalID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabPermissionsByPortal"), GetNull(PortalID)), IDataReader)
        End Function
        Overrides Function GetTabPermissionsByTabID(ByVal TabID As Integer, ByVal PermissionID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetTabPermissionsByTabID"), TabID, PermissionID), IDataReader)
        End Function
        Overrides Sub DeleteTabPermissionsByTabID(ByVal TabID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteTabPermissionsByTabID"), TabID)
        End Sub
        Overrides Sub DeleteTabPermission(ByVal TabPermissionID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteTabPermission"), TabPermissionID)
        End Sub
        Overrides Function AddTabPermission(ByVal TabID As Integer, ByVal PermissionID As Integer, ByVal roleID As Integer, ByVal AllowAccess As Boolean, ByVal UserID As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddTabPermission"), TabID, PermissionID, GetRoleNull(roleID), AllowAccess, GetNull(UserID)), Integer)
        End Function
        Overrides Sub UpdateTabPermission(ByVal TabPermissionID As Integer, ByVal TabID As Integer, ByVal PermissionID As Integer, ByVal roleID As Integer, ByVal AllowAccess As Boolean, ByVal UserID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateTabPermission"), TabPermissionID, TabID, PermissionID, GetRoleNull(roleID), AllowAccess, GetNull(UserID))
        End Sub
        'Folders
        Overrides Function GetFoldersByPortal(ByVal PortalID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetFolders"), GetNull(PortalID), -1, ""), IDataReader)
        End Function
        Overloads Overrides Function GetFolder(ByVal PortalID As Integer, ByVal FolderID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetFolderByFolderID"), GetNull(PortalID), FolderID), IDataReader)
        End Function
        Overloads Overrides Function GetFolder(ByVal PortalID As Integer, ByVal FolderPath As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetFolderByFolderPath"), GetNull(PortalID), FolderPath), IDataReader)
        End Function
        Overrides Function AddFolder(ByVal PortalID As Integer, ByVal FolderPath As String, ByVal StorageLocation As Integer, ByVal IsProtected As Boolean, ByVal IsCached As Boolean, ByVal LastUpdated As Date) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddFolder"), GetNull(PortalID), FolderPath, StorageLocation, IsProtected, IsCached, GetNull(LastUpdated)), Integer)
        End Function
        Overrides Sub UpdateFolder(ByVal PortalID As Integer, ByVal FolderID As Integer, ByVal FolderPath As String, ByVal StorageLocation As Integer, ByVal IsProtected As Boolean, ByVal IsCached As Boolean, ByVal LastUpdated As Date)
            SqlHelper.ExecuteScalar(ConnectionString, QueryName("UpdateFolder"), GetNull(PortalID), FolderID, FolderPath, StorageLocation, IsProtected, IsCached, GetNull(LastUpdated))
        End Sub
        Overrides Sub DeleteFolder(ByVal PortalID As Integer, ByVal FolderPath As String)
            SqlHelper.ExecuteScalar(ConnectionString, QueryName("DeleteFolder"), GetNull(PortalID), FolderPath)
        End Sub
        'FolderPermission
        Overrides Function GetFolderPermission(ByVal FolderPermissionID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetFolderPermission"), FolderPermissionID), IDataReader)
        End Function
        Overrides Function GetFolderPermissionsByPortal(ByVal PortalID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetFolderPermissionsByPortal"), GetNull(PortalID)), IDataReader)
        End Function
        Overrides Function GetFolderPermissionsByFolderPath(ByVal PortalID As Integer, ByVal FolderPath As String, ByVal PermissionID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetFolderPermissionsByFolderPath"), GetNull(PortalID), FolderPath, PermissionID), IDataReader)
        End Function
        Overrides Sub DeleteFolderPermissionsByFolderPath(ByVal PortalID As Integer, ByVal FolderPath As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteFolderPermissionsByFolderPath"), GetNull(PortalID), FolderPath)
        End Sub
        Overrides Sub DeleteFolderPermission(ByVal FolderPermissionID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteFolderPermission"), FolderPermissionID)
        End Sub
        Overrides Function AddFolderPermission(ByVal FolderID As Integer, ByVal PermissionID As Integer, ByVal roleID As Integer, ByVal AllowAccess As Boolean, ByVal UserID As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddFolderPermission"), FolderID, PermissionID, GetRoleNull(roleID), AllowAccess, GetNull(UserID)), Integer)
        End Function
        Overrides Sub UpdateFolderPermission(ByVal FolderPermissionID As Integer, ByVal FolderID As Integer, ByVal PermissionID As Integer, ByVal roleID As Integer, ByVal AllowAccess As Boolean, ByVal UserID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateFolderPermission"), FolderPermissionID, FolderID, PermissionID, GetRoleNull(roleID), AllowAccess, GetNull(UserID))
        End Sub
        ' search engine
        Overrides Function GetSearchIndexers() As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSearchIndexers")), IDataReader)
        End Function
        Overrides Function GetSearchResultModules(ByVal PortalID As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSearchResultModules"), PortalID), IDataReader)
        End Function

        ' content search datastore
        Overrides Sub DeleteSearchItems(ByVal ModuleID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteSearchItems"), ModuleID)
        End Sub
        Overrides Sub DeleteSearchItem(ByVal SearchItemId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteSearchItem"), SearchItemId)
        End Sub
        Overrides Sub DeleteSearchItemWords(ByVal SearchItemId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteSearchItemWords"), SearchItemId)
        End Sub
        Overrides Function AddSearchItem(ByVal Title As String, ByVal Description As String, ByVal Author As Integer, ByVal PubDate As Date, ByVal ModuleId As Integer, ByVal Key As String, ByVal Guid As String, ByVal ImageFileId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddSearchItem"), Title, Description, GetNull(Author), GetNull(PubDate), ModuleId, Key, Guid, ImageFileId), Integer)
        End Function
        Overrides Function GetSearchCommonWordsByLocale(ByVal Locale As String) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSearchCommonWordsByLocale"), Locale), IDataReader)
        End Function
        Overrides Function GetDefaultLanguageByModule(ByVal ModuleList As String) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetDefaultLanguageByModule"), ModuleList), IDataReader)
        End Function
        Overrides Function GetSearchSettings(ByVal ModuleId As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSearchSettings"), ModuleId), IDataReader)
        End Function
        Overrides Function GetSearchWords() As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSearchWords")), IDataReader)
        End Function
        Overrides Function AddSearchWord(ByVal Word As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddSearchWord"), Word), Integer)
        End Function
        Overrides Function AddSearchItemWord(ByVal SearchItemId As Integer, ByVal SearchWordsID As Integer, ByVal Occurrences As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddSearchItemWord"), SearchItemId, SearchWordsID, Occurrences), Integer)
        End Function
        Overrides Sub AddSearchItemWordPosition(ByVal SearchItemWordID As Integer, ByVal ContentPositions As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddSearchItemWordPosition"), SearchItemWordID, ContentPositions)
        End Sub
        Overrides Function GetSearchResults(ByVal PortalID As Integer, ByVal Word As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSearchResults"), PortalID, Word), IDataReader)
        End Function
        Overrides Function GetSearchItems(ByVal PortalID As Integer, ByVal TabID As Integer, ByVal ModuleID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSearchItems"), GetNull(PortalID), GetNull(TabID), GetNull(ModuleID)), IDataReader)
        End Function
        Overrides Function GetSearchItem(ByVal ModuleID As Integer, ByVal SearchKey As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetSearchItem"), GetNull(ModuleID), SearchKey), IDataReader)
        End Function
        Overrides Sub UpdateSearchItem(ByVal SearchItemId As Integer, ByVal Title As String, ByVal Description As String, ByVal Author As Integer, ByVal PubDate As Date, ByVal ModuleId As Integer, ByVal Key As String, ByVal Guid As String, ByVal HitCount As Integer, ByVal ImageFileId As Integer)
            SqlHelper.ExecuteScalar(ConnectionString, QueryName("UpdateSearchItem"), SearchItemId, Title, Description, GetNull(Author), GetNull(PubDate), ModuleId, Key, Guid, HitCount, ImageFileId)
        End Sub
        'Lists
        Overrides Function GetLists(ByVal PortalID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetLists"), PortalID), IDataReader)
        End Function
        Overrides Function GetList(ByVal ListName As String, ByVal ParentKey As String, ByVal PortalID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetList"), ListName, ParentKey, PortalID), IDataReader)
        End Function
        Overrides Function GetListEntry(ByVal ListName As String, ByVal Value As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetListEntry"), ListName, Value, -1), IDataReader)
        End Function
        Overrides Function GetListEntry(ByVal EntryID As Integer) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetListEntry"), String.Empty, String.Empty, EntryID), IDataReader)
        End Function
        Overrides Function GetListEntriesByListName(ByVal ListName As String, ByVal ParentKey As String) As IDataReader
            Return CType(SqlHelper.ExecuteReader(ConnectionString, QueryName("GetListEntries"), ListName, ParentKey), IDataReader)
        End Function
        Overrides Function AddListEntry(ByVal ListName As String, ByVal Value As String, ByVal Text As String, ByVal ParentID As Integer, ByVal Level As Integer, ByVal EnableSortOrder As Boolean, ByVal DefinitionID As Integer, ByVal Description As String, ByVal PortalID As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddListEntry"), ListName, Value, Text, ParentID, Level, EnableSortOrder, DefinitionID, Description, PortalID), Integer)
        End Function
        Overrides Sub UpdateListEntry(ByVal EntryID As Integer, ByVal Value As String, ByVal Text As String, ByVal Description As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateListEntry"), EntryID, Value, Text, Description)
        End Sub
        Overrides Sub DeleteListEntryByID(ByVal EntryID As Integer, ByVal DeleteChild As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteListEntryByID"), EntryID, DeleteChild)
        End Sub
        Overrides Sub DeleteList(ByVal ListName As String, ByVal ParentKey As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteList"), ListName, ParentKey)
        End Sub
        Overrides Sub DeleteListEntryByListName(ByVal ListName As String, ByVal Value As String, ByVal DeleteChild As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeleteListEntryByListName"), ListName, Value, DeleteChild)
        End Sub
        Overrides Sub UpdateListSortOrder(ByVal EntryID As Integer, ByVal MoveUp As Boolean)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdateListSortOrder"), EntryID, MoveUp)
        End Sub
        'portal alias
        Overrides Function GetPortalAlias(ByVal PortalAlias As String, ByVal PortalID As Integer) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortalAlias"), PortalAlias, PortalID)
        End Function
        Overrides Function GetPortalByPortalAliasID(ByVal PortalAliasId As Integer) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortalByPortalAliasID"), PortalAliasId)
        End Function
        Overrides Sub UpdatePortalAlias(ByVal PortalAlias As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdatePortalAliasOnInstall"), PortalAlias)
        End Sub
        Overrides Sub UpdatePortalAliasInfo(ByVal PortalAliasID As Integer, ByVal PortalID As Integer, ByVal HTTPAlias As String)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("UpdatePortalAlias"), PortalAliasID, PortalID, HTTPAlias)
        End Sub
        Overrides Function AddPortalAlias(ByVal PortalID As Integer, ByVal HTTPAlias As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(ConnectionString, QueryName("AddPortalAlias"), PortalID, HTTPAlias), Integer)
        End Function
        Overrides Sub DeletePortalAlias(ByVal PortalAliasID As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("DeletePortalAlias"), PortalAliasID)
        End Sub
        Overrides Function GetPortalAliasByPortalID(ByVal PortalID As Integer) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortalAliasByPortalID"), PortalID)
        End Function
        Overrides Function GetPortalAliasByPortalAliasID(ByVal PortalAliasID As Integer) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, QueryName("GetPortalAliasByPortalAliasID"), PortalAliasID)
        End Function
        'event Queue
        Overrides Function AddEventMessage(ByVal eventName As String, ByVal priority As Integer, ByVal processorType As String, ByVal processorCommand As String, ByVal body As String, ByVal sender As String, ByVal subscriberId As String, ByVal authorizedRoles As String, ByVal exceptionMessage As String, ByVal sentDate As Date, ByVal expirationDate As Date, ByVal attributes As String) As Integer
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("AddEventMessage"), eventName, priority, processorType, processorCommand, body, sender, subscriberId, authorizedRoles, exceptionMessage, sentDate, expirationDate, attributes)
        End Function
        Overrides Function GetEventMessages(ByVal eventName As String) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, QueryName("GetEventMessages"), eventName)
        End Function
        Overrides Function GetEventMessagesBySubscriber(ByVal eventName As String, ByVal subscriberId As String) As IDataReader
            Return SqlHelper.ExecuteReader(ConnectionString, QueryName("GetEventMessagesBySubscriber"), eventName, subscriberId)
        End Function
        Overrides Sub SetEventMessageComplete(ByVal eventMessageId As Integer)
            SqlHelper.ExecuteNonQuery(ConnectionString, QueryName("SetEventMessageComplete"), eventMessageId)
        End Sub

#End Region
#Region " Helper Methods "
        Private Function ExceptionString(ByVal objException As Exception, ByVal Sql As String) As String
            Try
                Dim sbExceptions As New StringBuilder
                With sbExceptions
                    .Append(objException.ToString)
                    .Append(Environment.NewLine)
                    .Append(Environment.NewLine)
                    .Append(Sql)
                    .Append(Environment.NewLine)
                    .Append(Environment.NewLine)
                End With
                Return sbExceptions.ToString
            Catch ex As Exception
                SendExceptionToAdmin(ex)
                Return String.Empty
            End Try
        End Function
        Private Function QueryName(ByVal SpName As String) As String
            Try
                ' validation
                'If String.IsNullOrEmpty(SpName) Then _
                '    Throw New ArgumentNullException("The SpName argument in the QueryName method cannot be null/empty!")
                Return String.Concat(DbOwnerQualifier, SpName)
            Catch ex As Exception
                SendExceptionToAdmin(ex)
                Return String.Empty
            End Try
        End Function
#Region " For Email Methods "
        Private p_AdminName As String = "YOUR NAME"
        Private p_AdminEmail As String = "[email protected]"
        Private p_SmtpHostAddress As String = System.Web.Configuration.WebConfigurationManager.AppSettings.Item("MailServer").ToString
        ''' 
        ''' ServerVariableText - the HTML listing of the server variables
        '''
        ''' String
        ''' String - HTML representation of the Request.ServerVariables object for e-mails
        '''
        Public Shared ReadOnly Property ServerVariableCollectionString(Optional ByVal ReturnAsHtml As Boolean = True) As String
            Get
                Dim strValue As String = String.Empty
                Try
                    ' load the value from cache (if you can)
                    If Not HttpContext.Current.Session("SERVER_VARIABLES") Is Nothing Then _
                        strValue = HttpContext.Current.Session("SERVER_VARIABLES").ToString
                Catch ex As Exception
                    ' do nothing
                    ' a problem occurred (the calling thread does not have state information)
                End Try
                Select Case String.IsNullOrEmpty(strValue)
                    Case True
                        Try
                            ' build the servervariable collection into a string value
                            Dim sbText As New Text.StringBuilder
                            Dim intI As Integer
                            For intI = 0 To HttpContext.Current.Request.ServerVariables.Count - 1
                                With sbText
                                    .Append(HttpContext.Current.Request.ServerVariables.Keys(intI).ToString)
                                    .Append(": ")
                                    .Append(HttpContext.Current.Request.ServerVariables.Item(intI).ToString)
                                    ' append the proper new line designation
                                    If ReturnAsHtml Then .Append("
") Else .Append(Environment.NewLine)
                                End With
                            Next
                            HttpContext.Current.Session.Add("SERVER_VARIABLES", sbText.ToString)
                            ' return the newly created string
                            Return sbText.ToString
                        Catch ex As Exception
                            ' a problem occurred (the calling thread does not have state information)
                            Return "UNABLE TO RETRIEVE SERVER VARIABLE COLLECTION"
                        End Try
                    Case Else
                        Return strValue
                End Select
            End Get
        End Property
        ''' 
        ''' SendMailToAdmin - this method sends an e-mail to the web site administrator
        '''
        ''' String - the text used as the message subject
        ''' String - the text used to create the message body
        ''' BodyType - the type of e-mail message you are sending (default = HTML)
        '''
        Private Sub SendMailToAdmin(ByVal SubjectText As String, ByVal BodyText As String, _
            Optional ByVal MessageBodyType As BodyType = BodyType.Html)
            Dim mailObj As New System.Net.Mail.MailMessage
            With mailObj
                .Body = BodyText
                .From = New System.Net.Mail.MailAddress(p_AdminEmail, p_AdminName)
                .Sender = New System.Net.Mail.MailAddress(p_AdminEmail, p_AdminName)
                .Subject = String.Concat(HttpContext.Current.Request.ServerVariables("SERVER_NAME"), SubjectText)
                .To.Add(New System.Net.Mail.MailAddress(p_AdminEmail, p_AdminName))
                Select Case MessageBodyType
                    Case BodyType.Html
                        .IsBodyHtml = True
                        .Body &= "

"
                    Case Else
                        .IsBodyHtml = False
                End Select
            End With
            Dim smtpObj As New System.Net.Mail.SmtpClient(p_SmtpHostAddress)
            With smtpObj
                .Credentials = New System.Net.NetworkCredential(p_AdminEmail, "YOURPASSWORD")
                .Send(mailObj)
            End With
        End Sub
        ''' 
        ''' SendExceptionToAdmin - this method sends an e-mail containing an exception to the web site administrator
        '''
        ''' Exception - the exception object
        ''' (optional) MailAddress - this can be used to copy the e-mail to someone else
        '''
        Private Sub SendExceptionToAdmin(ByVal ex As Exception, Optional ByVal CopyTo As System.Net.Mail.MailAddress = Nothing)
            ' create the message body
            Dim sbBody As New Text.StringBuilder
            With sbBody
                .Append("MESSAGE:
")
                .Append(ex.Message)
                .Append("

SOURCE: ")
                .Append(ex.Source)
                .Append("

STACK TRACE:
")
                .Append(ex.StackTrace.Replace(" at ", "
at "))
                .Append("

IP ADDRESS: ")
                .Append(HttpContext.Current.Request.ServerVariables("REMOTE_HOST"))
                .Append("

")
                .Append(HttpContext.Current.Request.ServerVariables("ALL_HTTP"))
                .Append("

")
                .Append(ServerVariableCollectionString)
                .Append("

")
            End With
            ' create the e-mail
            Dim mailObj As New System.Net.Mail.MailMessage
            With mailObj
                If Not CopyTo Is Nothing Then .CC.Add(CopyTo)
                .Body = sbBody.ToString
                .From = New System.Net.Mail.MailAddress(p_AdminEmail, p_AdminName)
                .Sender = New System.Net.Mail.MailAddress(p_AdminEmail, p_AdminName)
                .Subject = String.Concat(HttpContext.Current.Request.ServerVariables("SERVER_NAME"), " - *** SERVER WEB SITE EXCEPTION ***")
                .Priority = System.Net.Mail.MailPriority.High
                .To.Add(New System.Net.Mail.MailAddress(p_AdminEmail, p_AdminName))
                .IsBodyHtml = True
            End With
            ' send the e-mail
            Dim smtpObj As New System.Net.Mail.SmtpClient(p_SmtpHostAddress)
            With smtpObj
                .Credentials = New System.Net.NetworkCredential(p_AdminEmail, "YOURPASSWORD")
                .Send(mailObj)
            End With
        End Sub
        ''' 
        ''' BodyType - an enumeration to designate the message body type of an e-mail
        '''
        '''
        Private Enum BodyType
            '''
            ''' Html - this will format the message using HTML
            '''
            '''
            Html
            '''
            ''' PlainText - this will formation the message, ignoring HTML
            '''
            '''
            PlainText
        End Enum
#End Region
#End Region
    End Class
End Namespace

Optimized SqlDataProvider class file for DNN 4.05.03

DNN v4.05.03 SqlDataProvider Optimized Class File

[DOWNLOAD]: DNN v4.05.03 SqlDataProvider Optimized Class File

[DOWNLOAD] DNN v4.05.03 Optimized SqlDataProvider Class File



blog comments powered by Disqus