Foros del Web » Programación para mayores de 30 ;) » .NET »

Error al ejecutar un SP con VB

Estas en el tema de Error al ejecutar un SP con VB en el foro de .NET en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 10/11/2011, 16:29
 
Fecha de Ingreso: abril-2010
Mensajes: 23
Antigüedad: 13 años, 11 meses
Puntos: 0
Pregunta 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

Etiquetas: visual
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:46.