Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/03/2009, 20:56
principefreddy
 
Fecha de Ingreso: julio-2008
Mensajes: 205
Antigüedad: 15 años, 10 meses
Puntos: 1
Sonrisa Error en la conexion

BUENAS.. TENGO UN ERROR Y NO SE QUE HACER.

RESULTA QUE TENGO UN MENU. Y CUANDO ENTRO AL MENU Y LUEGO ENTRO A UN SUB MENU ENTRA MUY BIEN. PERO SI LE DOY CERRAR AL SUB MENU Y VULELVO A ENTRAR ME MUESTRA ESTE ERROR:

rs.Open "SELECT * FROM registro", nc, adOpenDynamic, adLockOptimistic

ESA LINEA DE CODIGO LA TENGO EN PROCEDIMIENTO PARA CARGAR UN LISTVIEW

ALGUIEN ME PUEDE AYUDAR???

Y BUENO EN EL MODULO TENGO LO SIGUIENTE
Option Explicit
Public nc As New ADODB.Connection
Public rs As New ADODB.Recordset
'Aqui inicia el programa.
Sub Main()
On Error Resume Next
Call Conectar_Basedatos
MDIMenu.Show
End Sub
Private Sub Conectar_Basedatos()
Dim sUbicacion As String

'Para controlar los errores...
On Error GoTo ErrorConexion
sUbicacion = App.Path & "\bd1.mdb"

With nc
'Esto es para las bases de datos de Access.
.Provider = "Microsoft.Jet.OLEDB.4.0"
'Donde está la base de datos.
.Properties("Data Source").Value = sUbicacion
'Otras propiedades necesarias...
.Properties("Persist Security Info").Value = False
'Abrimos la conexión a la base de datos...
.Open
End With
Exit Sub


ErrorConexion:
MsgBox "Error No. " & Err.Number & vbCrLf & "Descripción: " & Err.Description, vbCritical, "Erro fatal"
Set nc = Nothing
End
End Sub

Y EN EL BOTON DE CERRAR EL FORMULARIO TENGO LO SIGUIENTE:
cerramos la conexión, SIEMPRE!!!
nc.Close
'y descargamos la memoria SIEMPRE!!!
Set nc = Nothing
Unload Me