Private c As ADODB.Connection
Private rst As ADODB.Recordset
'********************propiedades del componente*************************
Private gsConsulta As String
Private mNumRegistro As Integer
Public Property Let consulta(ByVal sql As String)
gsConsulta = sql
End Property
Public Property Get consulta() As String
consulta = gsConsulta
End Property
Public Property Get numRegistro() As Integer
On Error GoTo err_numRegistro
numRegistro = mNumRegistro
Exit Sub
err_numRegistro:
'MsgBox "Primero hay que ejecutar la consulta antes de acceder a esta propiedad"
MsgBox "Num registro :" & Err.Description
End Property
'**********************metodos del componente**********************
Public Function ejecutarconsulta() As Variant
On Error GoTo err_conexion
Dim varRecords As Variant
If IsNull(consulta) Then
MsgBox "No se puede continuar, no especifico ninguna consulta"
Else
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.Open gsConsulta, c, adOpenKeyset, , adCmdText
'Set varArray = recordset.GetRows(numrows)
mNumRegistro = rst.RecordCount
varRecords = rst.GetRows(rst.RecordCount)
ejecutarconsulta = varRecords
End If
Exit Function
err_conexion:
MsgBox "Ejecutar :" & Err.Description
End Function
'***************************eventos del componente******************************
Private Sub class_Initialize()
On Error GoTo err_class_Initialize
Set c = New ADODB.Connection
c.ConnectionString = "Provider=SIBPROvider.2;Data Source=localhost:d:\gestionADC.gdb;Persist Security Info=False"
c.CursorLocation = adUseClient
c.Open
Exit Sub
err_class_Initialize:
MsgBox "Inicializar :" & Err.Description
End Sub
Private Sub class_Terminate()
On Error GoTo err_terminate
rst.Close
Set rst = Nothing
c.Close
Set c = Nothing
'MsgBox "termina"
Exit Sub
err_terminate:
MsgBox Err.Description
End Sub