Visual Basic - error 424 se requiere un objeto

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

error 424 se requiere un objeto

Publicado por daniel (1 intervención) el 15/05/2014 20:13:58
Me da el error famoso pero no lo puedo descrubir, es en visual basic 6 conectado a sql 2008 r2, pongo en donde se me para el error: Set oRSet2 = Server.CreateObject("ADODB.RecordSet")

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
Dim cString As String
Dim oConn As ADODB.Connection
Dim oConnnov As ADODB.Connection
Dim oConnedi As ADODB.Connection
Dim oConnexa As ADODB.Connection
Dim oRSet As ADODB.Recordset
Dim oRSet2 As ADODB.Recordset
Dim oRSet3 As ADODB.Recordset
Dim oRSet4 As ADODB.Recordset
Dim oRSet5 As ADODB.Recordset
Public SECTOR As String
Public name_file As String
 
 
Private Sub Command1_Click()
    rutina (oConnnov)
End Sub
 
Private Sub Command3_Click()
    rutina (oConn)
End Sub
 
Public Sub rutina(BD As String)
Dim INICIAL As Date
Dim FINAL As Date
 
INICIAL = DTPicker1.Value
FINAL = DTPicker2.Value
 
 
lblAVISO.ForeColor = vbRed
lblAVISO = " PROCESANDO....."
lblAVISO.Refresh
Me.MousePointer = 11
 
'ARMA LA CONSULTA
 cString = " SELECT * FROM (  select hCob.Cod_Cli, maecli.nombre, sum ( hCob.Imp_Cob / 1.21 ) Imp_Cob   From hCob    inner join maecli on hCob.cod_cli = maecli.cod_cli  where hCob.Imp_Retenc = 0 and maecli.cod_iva = '1' and hCob.fec_cob between '" & INICIAL & "' and  '" & FINAL & "'  group by hCob.Cod_Cli, maecli.nombre ) subcons where (Imp_Cob / 1.21 ) > '12000' order by nombre"
'TRAE LA CONSULTA
 
aca me marca en amarillo   Set oRSet2 = Server.CreateObject("ADODB.RecordSet")
 
oRSet2.Open cString, BD, 2
 
 
'CHEQUEA QUE SE HAYAN ENCONTRADO REGISTROS Y CARGA LA GRILLA
If oRSet2.BOF And oRSet2.EOF Then
    'Label1.Caption = 0
    Set grilla.DataSource = oRSet2
    lblAVISO.ForeColor = vbRed
    lblAVISO = " No se encontraron registros"
    Me.MousePointer = 0
    Else
    'Label1.Caption = oRSet2.RecordCount
    Set grilla.DataSource = oRSet2
    Me.MousePointer = 0
    lblAVISO.ForeColor = &H8000&
    lblAVISO = " Se encontraron " & oRSet2.RecordCount & " registros"
End If
 
Me.MousePointer = 0
 
End Sub
 
 
Private Sub Command6_Click()
    rutina (oConnedi)
End Sub
 
Private Sub Command7_Click()
 
    rutina (oConnexa)
 
End Sub
 
Private Sub Command8_Click()
 
Unload Me
 End
 
End Sub
 
 
 
Private Sub Form_Load()
 
Me.Top = 0
Me.Left = Screen.Width / 2 - Me.Width / 2
 
DTPicker1.Value = Date
DTPicker2.Value = Date
 
INICIAL = Format(DTPicker1.Value, "yyyy/mm/dd")
FINAL = Format(DTPicker2.Value, "yyyy/mm/dd")
 
Set oConn = New ADODB.Connection
 
With oConn
    .Provider = "sqloledb"
    .Properties("Data Source").Value = "192.168.1.44"
    .Properties("User ID").Value = "dani"
    .Properties("Password").Value = "123456789"
    .Open
End With
 
Set oConnnov = New ADODB.Connection
 
With oConnnov
    .Provider = "sqloledb"
    .Properties("Data Source").Value = "escfssql01"
    .Properties("User ID").Value = "daniel"
    .Properties("Password").Value = "159753456258"
    .Open
End With
 
Set oConnedi = New ADODB.Connection
 
With oConnedi
    .Provider = "sqloledb"
    .Properties("Data Source").Value = "escfssql01"
    .Properties("User ID").Value = "danie"
    .Properties("Password").Value = "987654321"
    .Open
End With
 
Set oConnexa = New ADODB.Connection
 
With oConnexa
    .Provider = "sqloledb"
    .Properties("Data Source").Value = "escfssql01"
    .Properties("User ID").Value = "dan"
    .Properties("Password").Value = "321654987"
    .Open
End With
 
End Sub
 
Private Sub Form_Unload(Cancel As Integer)
oConn.Close
Set oConn = Nothing
End Sub
 
Private Sub grilla_Click()
Static Modo  As Boolean
If (grilla.MouseRow = 0) Then
    ' Ordena en forma ascendente
    If Modo Then
        grilla.Col = grilla.MouseCol
        grilla.Sort = 2
        Modo = False
    ' Ordena en forma descendente
    Else
        grilla.Col = grilla.MouseCol
        grilla.Sort = 1
        Modo = True
    End If
End If
 
End Sub
 
Private Sub cmdexporta_Click()
On Error GoTo ErrHandler
    CD.Filter = "Excel File(*.xls)|*.xls|Text File (*.txt)|*.txt"
    CD.FilterIndex = 1
    CD.ShowSave
    ExportarGrid grilla, CD.FileName, CD.FilterIndex
ErrHandler:
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Oscar

error 424 se requiere un objeto

Publicado por Oscar (63 intervenciones) el 31/05/2014 11:55:08
Has probado con:

Set oRSet2 = New ADODB.RecordSet

en lugar de

Set oRSet2 = Server.CreateObject("ADODB.RecordSet")

Otra cosa que he visto y me parece curiosa es que la conexión la pasas por referencia a una variable BD tipo String.. ¿Esto funciona?, vamos yo cuando paso las conexiones ADODB siempre las referencio a variables tipo Object.

Vamos yo usaría
Private Sub rutina (ByRef BD as Object)

Pero si eso te funciona normalmente con tus conexiones dimelo por que me resulta muy curioso
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar