Dim vArchivo As Integer
Dim vCadenaConexion As String
vArchivo = FreeFile
Open App.Path & "\ruta.txt" For Input As vArchivo
Line Input #vArchivo, vCadenaConexion
Close #vArchivo
Text1 = vCadenaConexion
Option Explicit
' variables para la conexión y el recordset
''''''''''''''''''''''''''''''''''''''''''''
Public cnn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public xRuta As String
Private Sub open_Ruta()
On Error GoTo ruta
Dim sRuta As String
Open App.Path & "\" & "ruta.TXT" For Input As #1
Do While Not EOF(1)
Input #1, sRuta
xRuta = sRuta
Loop
Close #1
Exit Sub
On Error GoTo 0
ruta:
MsgBox "Error no se encontro el archivo Ruta.txt" & vbCrLf & "La aplicación se cerrará por medidas de Seguridad", vbCritical, "InvenSoft"
End
End Sub
Sub Main()
On Error Resume Next
open_Ruta 'Abro el archivo
IniciarConexion 'Le asigno el string de conex al Adodb
FrmPrincipal.Show 'Ejecuto mi form principal
End Sub
' abre
Public Sub IniciarConexion()
With cnn
.CursorLocation = adUseClient
.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\" & xRuta & ";Persist Security Info=False"
End With
End Sub
' cierra
Sub Desconectar()
On Local Error Resume Next
rs.Close
Set rs = Nothing
cnn.Close
Set cnn = Nothing
End Sub
Adodc1.ConnectionString=Variable
Adodc1.RecordSource="Select * From Tabla Where Campo=condicion"
Adodc1.Refresh
ERES UN GENIO COMPADRE ME SIRVIO DE REAHUEVO :D :D :D :DJajajaja... Ok, de nada!