Attribute VB_Name = "Mod1" Option Explicit '/*************************************************************************/ '-- '-- Filename : MOD1.BAS '-- '-- Description: Hold global variables ( bas thing ) '-- Error routine '-- Hide /Show main menu '-- Get server names '-- '-- Called by : ALL '-- '-- Calls : '-- '-- Date : '-- Author : '-- '-- History : '-- '/*************************************************************************/ Public sSRVNameDMO As String ' Storage of the server name Public sPassword As String ' Storage of password if not trusted connection Public MySqlServer As SQLDMO.SQLServer 'Global SQL Server Public bConnected As Boolean ' How are we connected ? Public Function MainMenu(objFormName As Object) ' Function to hide main menu objFormName.Hide Set objFormName = Nothing frmMenu.Show frmMenu.SetFocus End Function Public Function FrmHide(objFormName As Object) ' Function to hide worker form and call main menu frmMenu.Hide objFormName.Show End Function Public Function GetSrvNames() Dim iCount As Integer Dim DMOApp As SQLDMO.Application Dim DMONameList As SQLDMO.NameList On Error GoTo Err ' Create the Application object Set DMOApp = New SQLDMO.Application ' Get the list of servers Set DMONameList = DMOApp.ListAvailableSQLServers 'Get the server names For iCount = 1 To DMONameList.Count frmMenu.cmbSrvName.AddItem DMONameList(iCount) Next ' Close the objects Set DMONameList = Nothing Set DMOApp = Nothing Err: Resume Next 'Replace with good error handling End Function Public Function SQL_CONNECTOR(objForName As Object) ' SQLDMO Connect string Set MySqlServer = CreateObject("SQLDMO.SQLServer") If bConnected = True Then MySqlServer.Connect ServerName:=sSRVNameDMO, _ Login:="sa", _ Password:=sPassword Else MySqlServer.LoginSecure = True MySqlServer.Connect ServerName:=sSRVNameDMO End If End Function