FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour metodo find de ado / Method find with ado
Posts: 400
Joined: Fri May 11, 2007 08:20 PM
metodo find de ado / Method find with ado
Posted: Fri Feb 08, 2019 12:50 AM
Amigos del foro:
Estoy pasando dbf a sql ... hasta ahora voy convirtiendo con exito, solo que tengo un incoveniente
Es posible buscar con el metodo find de ado mas de dos columnas?
Code (fw): Select all Collapse
oRsCli:Find("ruc ="+cRuc+" and ubica = "+cUbica+"")  // no funciona
oRsCli:Find("ruc ="+cRuc+"")                                              // si funciona


Friends:
Im passing from dbf to sql ... until now It's ok, but i have a problem
is it possible find on more fields with ADO?

Code (fw): Select all Collapse
oRsCli:Find("ruc ="+cRuc+" and ubica = "+cUbica+"")  // NOT run
oRsCli:Find("ruc ="+cRuc+"")                                              // run


Gracias
Gracias por su ayuda
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: metodo find de ado / Method find with ado
Posted: Fri Feb 08, 2019 11:26 AM
Hola Artu:
Recorda que si alguno de los campos es tipo texto, deberias ponerle las comillas para que lo encuentre...
Probaste asi?
Code (fw): Select all Collapse
oRsCli:Find("ruc ="+cRuc+" and ubica = '"+cUbica+"'")  // no funciona
Posts: 111
Joined: Sun Oct 09, 2005 03:09 PM
Re: metodo find de ado / Method find with ado
Posted: Fri Feb 08, 2019 03:37 PM

Efectivamente se debe formar la cadena SQL como si la estuvieras dando directamente en SQL SERVER MANAGEMENT STUDIO o algún otro, para tal efecto tendras que alternar entre " y ' (comillas dobles y tilde)para formar strings que incluyan otras strings anidadas
La string resultante final deberia verse tal como la tecleas para ejecutar el comando.
Puedes usar la funcion msgget(cmsg1,cmsg2,@variable1) para verla y editarla antes de enviarla
suponiendo que la string final esta en variable1

Saludos

Saludos

Atentamente

Jose F Dominguez Serafin

email admsoporte@gmail.com
Posts: 84
Joined: Wed Oct 24, 2007 12:48 PM
Re: metodo find de ado / Method find with ado
Posted: Fri Feb 08, 2019 05:31 PM
Creo recordar que en ADO la función find está definida para una única columna, por eso dejé de usarla al convertir mis programas de DBF a SQL.
Yo uso el comando Filter, de la siguiente forma :
Code (fw): Select all Collapse
oRsCli:Filter := "ruc = " + cRuc + " and ubica = " + cUbica

Revisa como te indican los otros compañeros que si la variables son String debes incluir un apóstrofe ' al inicio y fin del String.

Un saludo.
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: metodo find de ado / Method find with ado
Posted: Fri Feb 08, 2019 10:34 PM
Artu01


oRsCli: Filter : = "ruc =" + cRuc + "and locate =" + cUbica


Try it this way

Code (fw): Select all Collapse
oRsCli:Filter := "[ruc] =  '"+cRuc+"' and [locate] = '"+cUbica+"'"


Filter is faster than Find .. if you use the find method you have to rewind the recordset to the beginning .. oRsCli:MoveFirst() .. then use the find method .. as you will notice ( for clarity ) I use brackets [] to designate table fields .. and character values ( as mentioned above ) have to be surrounded with a single quote.

Rick Lipkin
Posts: 400
Joined: Fri May 11, 2007 08:20 PM
Re: metodo find de ado / Method find with ado
Posted: Sat Feb 09, 2019 02:04 PM

Gracias amigos por sus repuestas
Con filter corre ok pero con find no corre, lei que find no acepta mas de una columna entonces
tengo duda el siguiente select que haga obtendre menos filas por la aplicacion del filtro?

Thank you guys for their responses
With filter run ok but with find not run, i read that more than one column not is accepted by find so
i have a dude the next select that do the recordset shows less rows by the effect of the filter?

fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: metodo find de ado / Method find with ado
Posted: Sat Feb 09, 2019 02:24 PM
Artu01

Find works basically the same way ... :Find is like a function and you have to pass the search parameters within the () .. :Find searches for the first matching record where Filter will retrieve all records that match your query.

Code (fw): Select all Collapse
oRsCli:MoveFirst()
oRsCli:Find( "[ruc] = '" + cRuc + "' and [locate] = '" + cUbica + "'" )


Rick Lipkin

Continue the discussion