July 7, 2003

UnregisterEnterpriseService – Unregister an Enterprise Service from the COM+ Catalog

‘ Unregister an Enterprise Service from the COM+ Catalog’ Note: requires a reference to the System.EnterpriseServices.dll assembly’ Note: applicationID is the name of the COM+ application that contains the ‘ components in the assembly – it can be Nothing’ This version identify the enterprise service with its path’ Example: UnregisterEnterpriseService(“C:TempTestService.dll”,

ExecuteSqlScripts – Executing an array of script files

‘ Execute an array of sql script files with batch statements,’ by using the same SqlCommand object’ – connString is the connection string for the destination database” Example:’ Dim connString As String = “server=(local);Persist Security ‘ Info=False;Integrated Security=SSPI;database=TestDB”‘ Dim script1 As String = “C:ScriptsCreateDbTables.sql”‘ Dim script2 As String = “C:ScriptsCreateDbSprocs.sql”‘

GetOsqlPath – Get the path of the SQL Server’s OSQL.exe utility

‘ Get the path of the SQL Server’s OSQL.exe utilityFunction GetOsqlPath() As String Dim regKey As Microsoft.Win32.RegistryKey = _ Microsoft.Win32.Registry.LocalMachine.OpenSubKey( _ “SOFTWAREMicrosoftMicrosoft SQL Server80ToolsClientSetup”) If regKey Is Nothing Then Return “” End If Dim osqlPath As String = System.IO.Path.Combine(CType(regKey.GetValue _ (“SQLPath”), String), “Binnosql.exe”) regKey.Close() Return osqlPathEnd Function

RegisterEnterpriseService – Register an Enterprise Service in the COM+ Catalog

‘ Register an Enterprise Service in the COM+ Catalog’ Note: requires a reference to the System.EnterpriseServices.dll assembly’ This version identify the enterprise service with its path’ Example: RegisterEnterpriseService(“C:TempTestService.dll”)Sub RegisterEnterpriseService(ByVal servicePath As String) Dim appID, typeLib As String Dim rh As New System.EnterpriseServices.RegistrationHelper rh.InstallAssembly(servicePath, appID, typeLib, System.EnterpriseServices. _ InstallationFlags.FindOrCreateTargetApplication)End Sub’ This

GetSqlPlusPath – Get the path of the Oracle’s SqlPlus.exe utility

‘ Get the path of the Oracle’s SqlPlus.exe utilityFunction GetSqlPlusPath() As String Dim regKey As Microsoft.Win32.RegistryKey = _ Microsoft.Win32.Registry.LocalMachine.OpenSubKey(“SOFTWAREORACLE”) If regKey Is Nothing Then Return “” End If Dim sqlplusPath As String = System.IO.Path.Combine(CType(regKey.GetValue _ (“ORACLE_HOME”), String), “binsqlplus.exe”) regKey.Close() Return sqlplusPathEnd Function