Dim cnx1 As ADODB.Connection
Set cnx1 = New ADODB.Connection
cnx1.Open "provider=IBMDA400;data source=NOMBRE_SISTEMA; , , -1"
Dim cmd1 As ADODB.Command
Set cmd1 = New ADODB.Command
Set cmd1.ActiveConnection = Cnx1
cmd1.Properties(16).Value = 7 'Updatability
'Asignando el recordset a una tabla.
cmd1.CommandType = adCmdTable
cmd1.CommandText = _
"/QSYS.LIB/MILIBRERIA.LIB/MIOBJ.FILE (*FIRST, *NONE)"
cmd1.Parameters.Append cmd1.CreateParameter("P1", adChar, adParamInput, 1)
Dim rs1 As ADODB.Recordset
Dim var1 As Variant, var2 As Variant
Set rs1 = cmd1.Execute(var1, var2, adCmdTable)
MsgBox rs1.RecordCount
'Asignando el recordset a un cursor SQL.
Dim rs2 As ADODB.Recordset
cmd1.CommandType = adCmdText
cmd1.CommandText = "SELECT * FROM MILIBRERIA.MIOBJ"
Set rs2 = cmd1.Execute()
MsgBox rs2.RecordCount
Set rs1 = Nothing
Set rs2 = Nothing
Set cmd1 = Nothing
cnx1.Close
Set cnx1 = Nothing