MARIADB estoy seguro que tiene datos pero...

Post Reply
User avatar
goosfancito
Posts: 1956
Joined: Fri Oct 07, 2005 7:08 pm

MARIADB estoy seguro que tiene datos pero...

Post by goosfancito »

Hola.
Esta consulta no me devuelve valores y estoy seguro que tiene y existe ese dato

Code: Select all | Expand

 
function buscart(cDato)
 LOCAL oDatos := ::oCnx:Execute( "SELECT id, nombre FROM tbdistribuidores WHERE tbdistribuidores.nombre =" + AllTrim( cDato ) )
...
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
JoseAlvarez
Posts: 811
Joined: Sun Nov 09, 2014 5:01 pm

Re: MARIADB estoy seguro que tiene datos pero...

Post by JoseAlvarez »

Si el dato a buscar es alfanumerico, debes encerrarlo entre comillas simples.
Nombre = ' "+alltrim(cDato)+" ' ; "
"Los errores en programación, siempre están entre la silla y el teclado..."

Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin

Carora, Estado Lara, Venezuela.
User avatar
carlos vargas
Posts: 1721
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: MARIADB estoy seguro que tiene datos pero...

Post by carlos vargas »

de la ayuda de fwh
http://wiki.fivetechsoft.com/doku.php?id=fivewin_class_fwmariaconnection

Code: Select all | Expand


Execute
SqlQuery        (cSqlStatement, [aParams], [lShowError := .f.]) –> uResult
uResult can be
a) nil if there is no result or if error occured.
In case of error, oCn:nError and oCn:cError provide teh error information
Optionally setting lShowError displays ther error or result of sql statement,
b) Numeric: In case of insert, update, etc indicating the affected rows
c) If the result is a result-set, it is returned as Multi-Dim array
 

lo mejor que puedes hacer es parametizarlo, ya que de esta forma "cDato" es tratado para evitar las sqlinjection.

Code: Select all | Expand


 LOCAL oDatos := ::oCnx:Execute( "SELECT id, nombre FROM tbdistribuidores WHERE tbdistribuidores.nombre =?",{ cDato } )
 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: MARIADB estoy seguro que tiene datos pero...

Post by nageswaragunupudi »

carlos vargas wrote:de la ayuda de fwh
http://wiki.fivetechsoft.com/doku.php?id=fivewin_class_fwmariaconnection

Code: Select all | Expand


Execute
SqlQuery        (cSqlStatement, [aParams], [lShowError := .f.]) –> uResult
uResult can be
a) nil if there is no result or if error occured.
In case of error, oCn:nError and oCn:cError provide teh error information
Optionally setting lShowError displays ther error or result of sql statement,
b) Numeric: In case of insert, update, etc indicating the affected rows
c) If the result is a result-set, it is returned as Multi-Dim array
 

lo mejor que puedes hacer es parametizarlo, ya que de esta forma "cDato" es tratado para evitar las sqlinjection.

Code: Select all | Expand


 LOCAL oDatos := ::oCnx:Execute( "SELECT id, nombre FROM tbdistribuidores WHERE tbdistribuidores.nombre =?",{ cDato } )
 


Yes.
Regards

G. N. Rao.
Hyderabad, India
User avatar
goosfancito
Posts: 1956
Joined: Fri Oct 07, 2005 7:08 pm

Re: MARIADB estoy seguro que tiene datos pero...

Post by goosfancito »

gracias a ambos tres!
fuunciono el de parametrizar.
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
Post Reply