Public Sub Opendb(Optional pstrBD As String)
Dim strBD As String
Dim strServidor As String
On Error GoTo Err_
If Trim(pstrBD) = "" Then
strBD = "BD_XXXXXX" 'NOMBRE DE LA BD
Else
strBD = pstrBD
End If
Set DB = New ADODB.Connection
'Estas variables contienen los datos necesarios para la conexion.
strServidor = "SERVIDOR"
DB.Open ("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Data Source=" & strServidor & ";Initial Catalog=" & strBD)
Exit Sub
Err_:
MsgBox Err.Description, vbInformation, "ERROR DE CONEXION A LA BASE DE DATOS"
End Sub