Nada me resulta!!
Tengo que lograr que un usuario
me seleccione la base de datos antes de
comenzar la ejecucion del programa
y una vez seleccionada no me la pida nunca mas.
tengo ideas de como hacerlo pero no me resultan.
asi que si tienen algun consejo
bien benido sea.
pd estoy trabajando con ado.
me seleccione la base de datos antes de
comenzar la ejecucion del programa
y una vez seleccionada no me la pida nunca mas.
tengo ideas de como hacerlo pero no me resultan.
asi que si tienen algun consejo
bien benido sea.
pd estoy trabajando con ado.
se me ocurre como pero tienes que generar la coneccion a mano
te mando el codigo
Option Explicit
'DECLARACION DE UN VARIABLE OBJETO DEL TIPO ADODB.CONNECTION
Public CON_COCINA As ADODB.Connection
Public rec_COCINA As ADODB.Recordset
Public Sub ConectarBD()
'On Error GoTo error:
'SE INSTANCIA EL OBJETO CON AUTO DEL TIPO CONNECTION
Set CON_COCINA = New ADODB.Connection
'CONFIGURACION DEL CON_AUTO
CON_COCINA.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Cocina"
'SE ABRE LA CONEXION
CON_COCINA.Open
'error:
' If Err.Number > 0 Then
' Err.Description
' Resume Next
' End If
End Sub
Public Sub DesconectarBD()
'SE CIERRA LA CONEXION
CON_COCINA.Close
'LIBERAR MEMORIA
Set CON_COCINA = Nothing
End Sub
Public Sub Ejecutar(strsql As String)
' On Error GoTo error:
Set rec_COCINA = New ADODB.Recordset
rec_COCINA.CursorLocation = adUseClient
rec_COCINA.Open strsql, CON_COCINA
'error:
' If Err.Number > 0 Then
' MsgBox Err.Description
' Resume Next
'End If
End Sub
cambia el connection string con la direccion de la base de datos
te mando el codigo
Option Explicit
'DECLARACION DE UN VARIABLE OBJETO DEL TIPO ADODB.CONNECTION
Public CON_COCINA As ADODB.Connection
Public rec_COCINA As ADODB.Recordset
Public Sub ConectarBD()
'On Error GoTo error:
'SE INSTANCIA EL OBJETO CON AUTO DEL TIPO CONNECTION
Set CON_COCINA = New ADODB.Connection
'CONFIGURACION DEL CON_AUTO
CON_COCINA.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Cocina"
'SE ABRE LA CONEXION
CON_COCINA.Open
'error:
' If Err.Number > 0 Then
' Err.Description
' Resume Next
' End If
End Sub
Public Sub DesconectarBD()
'SE CIERRA LA CONEXION
CON_COCINA.Close
'LIBERAR MEMORIA
Set CON_COCINA = Nothing
End Sub
Public Sub Ejecutar(strsql As String)
' On Error GoTo error:
Set rec_COCINA = New ADODB.Recordset
rec_COCINA.CursorLocation = adUseClient
rec_COCINA.Open strsql, CON_COCINA
'error:
' If Err.Number > 0 Then
' MsgBox Err.Description
' Resume Next
'End If
End Sub
cambia el connection string con la direccion de la base de datos
