Page 1 of 1

MARIADB estoy seguro que tiene datos pero...

Posted: Sat Oct 02, 2021 2:13 pm
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 ) )
...

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

Posted: Sat Oct 02, 2021 2:39 pm
by JoseAlvarez
Si el dato a buscar es alfanumerico, debes encerrarlo entre comillas simples.
Nombre = ' "+alltrim(cDato)+" ' ; "

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

Posted: Sat Oct 02, 2021 6:13 pm
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 } )
 

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

Posted: Sun Oct 03, 2021 1:28 am
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.

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

Posted: Mon Oct 04, 2021 9:58 pm
by goosfancito
gracias a ambos tres!
fuunciono el de parametrizar.