Hola,
Yo utilizo el objeto ADODB.Recordset para recorrer tablas SQL SERVER desde harbour
Ahora tengo que ejecutar un procedimiento almacenado y recorrer los registros que retorna.
¿Cómo se hace?
Muchas gracias
Daniel
La Reja Buenos Aires
Hi,
I use the ADODB.Recordset object to go through SQL SERVER tables from Harbour
Now I have to execute a stored procedure and go through the records it returns.
How do I do it?
Thanks
Daniel
La Reja Buenos Aires
Hola,
Pude ejecutar el procedimiento almacenado (eso creo), con el siguiente código
oConn := CreateObject("ADODB.Connection")
oConn:ConnectionString := "PROVIDER=SQLOLEDB;DATASOURCE=myserver;DATABASE=mydbname;UID=myuser;PWD=mypassword"
oConn:Open()
oConn:Execute("sp_copiar_diagrama '"+Str(nCodDes,3)+"', '"+Str(nCodHas,3)+"' ")
oConn:Close()
pero tengo que recorrer los registros que retorna y utilizando oConn como si fuese un ADODB.Recordset, no me deja
muchas gracias
***************************************************************************************************************************************************
Hello,
I was able to execute the stored procedure (I think), with the following code
oConn := CreateObject("ADODB.Connection")
oConn:ConnectionString := "PROVIDER=SQLOLEDB;DATASOURCE=myserver;DATABASE=mydbname;UID=myuser;PWD=mypassword"
oConn:Open()
oConn:Execute("sp_copiar_diagrama '"+Str(nCodDes,3)+"', '"+Str(nCodHas,3)+"' ")
oConn:Close()
but I have to go through the records that it returns and using oConn as if it were an ADODB.Recordset, it doesn't let me
thanks a lot
--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/6ef9d559-e67c-46a0-8a00-f4286600c494n%40googlegroups.com.
Estimado,
el retorno de oConn:Execute( ... ) de la llamada al procedimiento almacenado deberia ser un recordset que puedes recorrer , si es que el procedimiento almacendo devuelve un conjunto de registros.
Asi que tu codigo deberia quedar asi : orecordset :=
oConn:Execute(....) luego usas orecordset como habitualmente lo
haces ( ojo es un recordset de solo lectura por lo que no podras
hacer modificaciones en el )
Atte.,
Lautaro Moreira
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/00a701db5d0b%24c3c1c100%244b454300%24%40gmail.com.
Hola,
Cuando intento recorrer el recorset me da el siguiente error
WINOLE/1007 La operación no está permitida si el objeto está cerrado. (0x800A0E78): ADODB.Recordset
El código es:
rs:=win_oleCreateObject( "ADODB.Recordset" )
oConn := CreateObject("ADODB.Connection")
oConn:ConnectionString := "Provider=sqloledb;Data Source=10.200.0.46;Initial Catalog=Gecros;User Id=xxxxxx;Password=xxxxxxx;"
oConn:Open()
rs:=oConn:Execute("pa_getCompDeuda 1071088,1")
rs:MoveFirst() // el error sucede aquí
DO WHILE ! rs:EOF() // Procesar los registros retornados
//? "Columna1: ", oRS:Fields( "Columna1" ):Value
//? "Columna2: ", oRS:Fields( "Columna2" ):Value // Agrega más columnas según sea necesario
rs:MoveNext()
ENDDO // Cerrar el Recordset oRS:Close()
oConn:Close()
Gracias
De: harbou...@googlegroups.com <harbou...@googlegroups.com> En nombre de cod...@outlook.com
Enviado el: jueves, 2 de enero de 2025 09:28
Para: Harbour Users <harbou...@googlegroups.com>
--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/74335ffe-c3f8-4ad0-80b5-7eef609c0302n%40googlegroups.com.
rs := oconn:Execute( "CALL theprocedure" )
rs := oconn:Execute( "CALL theprocedure()" )
José M. C. Quintas
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/00e601db5d15%24d58bb1c0%2480a31540%24%40gmail.com.
Hola,
Te falta rs:open()
En tu codigo quedaria :
...
rs:= oconn:execute(...)
rs:open()
...
Atte.,
Lautaro Moreira
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/00e601db5d15%24d58bb1c0%2480a31540%24%40gmail.com.
Gracias Lautaro,
Cuando intento usar la variable de retorno del execute, me da este error:
WINOLE/1007 La operación no está permitida si el objeto está cerrado. (0x800A0E78): ADODB.Recordset
No se a que se debe
Gracias
Lautaro, le agregué el rs:open(), pero me sigue dando el mismo error
WINOLE/1007 La operación no está permitida si el objeto está cerrado. (0x800A0E78): ADODB.Recordset
En la línea siguiente:
DO WHILE !rs:EOF()
rs:MoveNext()
ENDDO
oRS:Close()
oConn:Close()
Gracias
DO WHILE ! oRS:EOF()
oRS:MoveNext()
ENDDO
oRS:Close()
oConn:Close()
Regards,
oConn := CreateObject("ADODB.Connection")
oConn:ConnectionString := "Provider=sqloledb;Data Source=10.200.0.46;Initial Catalog=Gecros;User Id=xxxxxx;Password=xxxxxxx;"
oConn:Open()
rs:=oConn:Execute("CALL `pa_getCompDeuda`( 1071088,1)")
// you should treat it like any other function putting the parameters within the parenthesis.
// if your parameter is of type character or date it should go between single quotes just like any SQL statement
// Using MySQL Note the character ` (don´t know what it is called) is not a ' single quote
rs:MoveFirst() // el error sucede aquí
DO WHILE ! rs:EOF() // Procesar los registros retornados
//? "Columna1: ", oRS:Fields( "Columna1" ):Value
//? "Columna2: ", oRS:Fields( "Columna2" ):Value // Agrega más columnas según sea necesario
rs:MoveNext()
ENDDO // Cerrar el Recordset oRS:Close()
I use this for MySQL, inside my ADOClass:
METHOD ExecuteProcedureNoReturn( ... ) CLASS ADOClass
LOCAL cSQL, aItem, aList := hb_AParams()
cSQL := "CALL " + aList[ 1 ]
hb_ADel( aList, 1, .T. )
cSQL += "("
FOR EACH aItem IN aList
cSQL += ValueSQL( aItem )
cSQL += iif( aItem:__ENumIsLast(), "", "," )
NEXT
cSQL += ")"
RETURN ::ExecuteNoReturn( cSQL )
METHOD ExecuteProcedure( ... ) CLASS ADOClass
LOCAL cSQL, aItem, aList := hb_AParams()
cSQL := "CALL " + aList[ 1 ]
hb_ADel( aList, 1, .T. )
cSQL += "("
FOR EACH aItem IN aList
cSQL += ValueSQL( aItem )
cSQL += iif( aItem:__ENumIsLast(), "", "," )
NEXT
cSQL += ")"
::Execute( cSQL )
RETURN Nil
Note: cnSQL is my class, not a connection.
cnSQL:ExecuteProcedure( "myprocedure", 125, 1 )
DO WHILE ! cnSQL:Eof()
cnSQL:MoveNext()
ENDDO
Note2: if a stored procedure does not return data, you do not have data.
José M. C. Quintas
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/014901db5d26%248dd07170%24a9715450%24%40gmail.com.
Hola David,
Me sigue dando error de sintaxis en rs:=oConn:Execute(…
Probé con ` y con ‘
Gracias
Hi David,
I keep getting a syntax error in rs:=oConn:Execute(…
I tried with ` and with ‘
Thanks

To view this discussion visit https://groups.google.com/d/msgid/harbour-users/e84894b3-6ed3-44f3-b0e0-6092d200dafen%40googlegroups.com.
Hola David,
Probé de la siguiente forma:
oConn := CreateObject("ADODB.Connection")
oConn:ConnectionString :="Provider=sqloledb;Data Source=x.x.x.x;Initial Catalog=Gecros;User Id=xxxxx;Password=xxxxx;"
oConn:Open()
rs:=oConn:Execute("EXECUTE pa_getCompDeuda 1071088,1")
rs:Open()
rs:MoveFirst() // el error sucede aquí
DO WHILE ! rs:EOF() // Procesar los registros retornados
rs:MoveNext()
ENDDO
Me sigue dando error al intentar usar el recordset
Las consultas select me funcionan sin problemas, pero nunca utilicé resultados de procedimientos almacenados desde harbour
En la misma pc funciona bien con SQL Server Managment Studio

Gracias
Daniel Goldberg
La Reja
Buenos Aires
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/57484231-e1d7-40bd-881f-db8848c0fad5n%40googlegroups.com.
Gracias Javier,
Hice los cambios según tu ej:
oConn := CreateObject("ADODB.Connection")
oConn:ConnectionString :="Provider=sqloledb;Data Source=x.x.x.x;Initial Catalog=Gecros;User Id=xxxx;Password=xxxxxx;"
oConn:Open()
rs:=oConn:Execute("EXEC pa_getCompDeuda @agecta=1071088,@entfac_id=1")
rs:MoveFirst() // el error sucede aquí
DO WHILE ! rs:EOF() // Procesar los registros retornados
rs:MoveNext()
ENDDO
Me sigue dando error al intentar recorrer el recordset (el erro dice: la operación no está permitida si el objeto está cerrado)
La conexión con el procedimiento almacenado se establece bien, porque si pongo un parámetro con el nombre mal, me dice que el parámetro no existe
También probé agregando:
rs:Open() y tampoco
y definiendo antes:
rs:=win_oleCreateObject( "ADODB.Recordset" ) y tampoco funcionó
El procedimiento almacenado se ejecuta pero no puedo recorrer los registros de respuesta como si lo puedo hacer con SQL Server Managment Studio
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/fb8b827c-f227-4950-bc0b-cf5f7da53fe6n%40googlegroups.com.
Hola David,
1*La conexión se realiza correctamente, de hecho si pongo mal un parámetro me dice el parámetro no existe
2*sin el open sigue dando el mismo error
3*El usuario tiene todos los permisos
4*es correcta, ya que los comandos select funcionan bien
5*Con la mismo comando sql que en SQL Mana… da el mismo error
Gracias
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/20432de9-7bb9-43b9-8e80-9aedfa4491f7n%40googlegroups.com.