
10/11/2011, 16:29
|
| | Fecha de Ingreso: abril-2010
Mensajes: 23
Antigüedad: 15 años Puntos: 0 | |
Error al ejecutar un SP con VB Hola como estan al realizar el recordset me sale el siguiente error La operacion no esta permitida si el objeto esta cerrado
Dim Conexion As ADODB.Connection
Dim Comando As ADODB.Command
Dim Cursor As ADODB.Recordset
Dim Instruccion As String
Dim URL As String
Dim j As Integer
Set Conexion = New ADODB.Connection
URL = "Provider=SQLOLEDB;Data Source=192.168.112.20;Initial Catalog=Prueba2;User ID=sa;Password=1234;"
Conexion.Open URL
MsgBox Conexion.State
Set Comando = New Command
With Comando
.ActiveConnection = URL
.CommandTimeout = 0
.CommandType = adCmdStoredProc
.CommandText = "VB_BK1"
Set Cursor = Comando.Execute
End With
Range("A1").Select
j = 1 en esta parte es donde me sale el error
If Not (Cursor.EOF) Or Not (Cursor.BOF) Then
Do While Not (Cursor.EOF)
Range("A" & j).Select
ActiveCell.FormulaR1C1 = Cursor.Fields(0).Value
Range("B" & j).Select
ActiveCell.FormulaR1C1 = Cursor.Fields(1).Value
Range("C" & j).Select
ActiveCell.FormulaR1C1 = Cursor.Fields(2).Value
Cursor.MoveNext
j = j + 1
Loop
Cursor.Close
Else
Set Cursor = Nothing
Set Comando = Nothing
Conexion.Close
Set Conexion = Nothing
End If |