metodo find de ado / Method find with ado

metodo find de ado / Method find with ado

Postby artu01 » 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: Select all  Expand view
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: Select all  Expand view
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
artu01
 
Posts: 397
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: metodo find de ado / Method find with ado

Postby cmsoft » 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: Select all  Expand view
oRsCli:Find("ruc ="+cRuc+" and ubica = '"+cUbica+"'")  // no funciona
User avatar
cmsoft
 
Posts: 1191
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: metodo find de ado / Method find with ado

Postby admsoporte » Fri Feb 08, 2019 3: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
admsoporte
 
Posts: 99
Joined: Sun Oct 09, 2005 3:09 pm
Location: Mexico

Re: metodo find de ado / Method find with ado

Postby gmart1 » Fri Feb 08, 2019 5: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: Select all  Expand view
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.
gmart1
 
Posts: 80
Joined: Wed Oct 24, 2007 12:48 pm
Location: Alhaurin de la Torre (MALAGA)

Re: metodo find de ado / Method find with ado

Postby Rick Lipkin » Fri Feb 08, 2019 10:34 pm

Artu01

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


Try it this way

Code: Select all  Expand view

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
User avatar
Rick Lipkin
 
Posts: 2629
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: metodo find de ado / Method find with ado

Postby artu01 » Sat Feb 09, 2019 2: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
artu01
 
Posts: 397
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: metodo find de ado / Method find with ado

Postby Rick Lipkin » Sat Feb 09, 2019 2: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: Select all  Expand view

oRsCli:MoveFirst()
oRsCli:Find( "[ruc] = '" + cRuc + "' and [locate] = '" + cUbica + "'" )
 


Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2629
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 7 guests