Hello,
I have been given the task of trying to update an old program in VB6 that uses SQLDMO.
The problem is VB6 is trying to connect with SQL Server 2014 (or 2016) and SQLDMO isn't supported.
When it tries to connect, the following error appears:
I haven't worked with VB6 in a long time and I'm pretty rusty.
How can I update the following code to work?
Thanks.
If at first you don't succeed, then sky diving wasn't meant for you!
I have been given the task of trying to update an old program in VB6 that uses SQLDMO.
The problem is VB6 is trying to connect with SQL Server 2014 (or 2016) and SQLDMO isn't supported.
When it tries to connect, the following error appears:
-2147024891;[SQL-DMO]Service Control Error: Access is denied.
I haven't worked with VB6 in a long time and I'm pretty rusty.
How can I update the following code to work?
Code:
'// Select a server.
Dim l_sngTime As Single, l_sngPauseTime As Single
Dim objDatabases As SQLDMO.Database
Dim objServer As SQLDMO.SQLServer
On Error GoTo ERR_Handler
frmSetup.MousePointer = vbHourglass
DoEvents
'// Determine the list of servers on the target.
Set objDatabases = New SQLDMO.Database
Set objServer = New SQLDMO.SQLServer
objServer.Name = Trim$(cboServers.Text)
*** ERRORS ON NEXT LINE ****
If objServer.Status = SQLDMOSvc_Stopped Then
objServer.Start True, Trim$(cboServers.Text), "", ""
DoEvents
l_sngTime = Timer
l_sngPauseTime = (60 * 3)
Do
If Timer > l_sngTime + l_sngPauseTime Then Exit Do
Loop Until objServer.Status = SQLDMOSvc_Running
Else
objServer.LoginSecure = True
objServer.Connect Trim$(cboServers.Text)
End If
For Each objDatabases In objServer.Databases
If Left$(objDatabases.Name, 2) = "qm" Then
lstSQLDBs.AddItem objDatabases.Name
End If
Next
Thanks.
If at first you don't succeed, then sky diving wasn't meant for you!