'--> Abrir base de datos con Ado Public Function AbreBD(ByVal Source As String, ByVal BaseDatos As String, ByVal User As String, ByVal Contraseña As String, ByVal sTipoMotor As Integer) As ADODB.Connection '--> Abrir una base de datos On Error GoTo ErroresAbrirBD
AbreBD = New ADODB.Connection If sTipoMotor = 0 Then '--> Abrir base de datos en SQL Server With AbreBD .ConnectionString = "Provider=SQLOLEDB;Password=" & Contraseña & ";Persist Security Info=True;User ID=" & User & ";Initial Catalog=" & BaseDatos & ";Data Source=" & Source & "" .ConnectionTimeout = 30 .Open() End With Else '--> Proveedor de datos Microsoft OLE DB para Microsoft Jet para Access If sTipoMotor = 1 Then With AbreBD .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & BaseDatos & ";Mode=Share Deny None;User ID=Admin" .Properties("Jet OLEDB:Database Password").Value = "" & Contraseña .Open() '.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & BaseDatos) End With End If End If Exit Function
ErroresAbrirBD: msg(Err.Number & " - " & Err.Description, "Reporteador", "mdoGlobal", "AbrirBD") End Function