Tengo una instalación de aplicación que instala antes una instancia de
MSDE2000A pero al intentar inicializar el "servicio" da errores. La primera
vez (recién instalado) da error, la segunda funciona, pero si paro el
servicio ya no vuelve a funcionar... ??
El código que uso en la función miembro de mi clase es el siguiente:
El valor de las variables es:
strInstancia = ".\PRUEBA"
strServidor = "(LOCAL)\PRUEBA"
strUsuario = "sa"
strClave = ""
El objeto SQLServer (DMO) es oSQLServer.
Y el error aparece siempre en el método "Start"
Public Sub Iniciar()
On Error GoTo Problema
'##########################################################################
'# Si existe el objeto, se inicializa... si no daría error...
#
'##########################################################################
If Not oSQLServer Is Nothing Then
oSQLServer.Disconnect
Set oSQLServer = Nothing
End If
'##########################################################################
'# Se intenta la identificación... si no (error) se inicia el servicio
#
'##########################################################################
Dim blnConectado As Boolean
Set oSQLServer = New SQLDMO.SQLServer
With oSQLServer
.Start True, strInstancia
.LoginTimeout = 30
.Connect strServidor, strUsuario, strClave
End With
Salida:
blnConectado = oSQLServer.VerifyConnection
If blnConectado = False Then
MsgBox "No ha podido establecerse conexión con la base de datos.",
vbCritical, "Error"
End
End If
Exit Sub
Problema:
If Err.Number = -2147023840 Or Err.Number = 1056 Or Err.Number = 440
Then
With oSQLServer
.LoginTimeout = 30
.Connect strServidor, strUsuario, strClave
End With
Else
MsgBox Err.Number & "; " & Err.Description, vbCritical, "Error"
End
End If
End Sub
Saludos,
Fegor
Leer las respuestas