MARIADB estoy seguro que tiene datos pero...

MARIADB estoy seguro que tiene datos pero...

Postby goosfancito » Sat Oct 02, 2021 2:13 pm

Hola.
Esta consulta no me devuelve valores y estoy seguro que tiene y existe ese dato
Code: Select all  Expand view
 
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
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

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

Postby JoseAlvarez » Sat Oct 02, 2021 2:39 pm

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
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

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

Postby carlos vargas » Sat Oct 02, 2021 6:13 pm

de la ayuda de fwh
http://wiki.fivetechsoft.com/doku.php?id=fivewin_class_fwmariaconnection
Code: Select all  Expand view

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 view

 LOCAL oDatos := ::oCnx:Execute( "SELECT id, nombre FROM tbdistribuidores WHERE tbdistribuidores.nombre =?",{ cDato } )
 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1686
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

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

Postby nageswaragunupudi » Sun Oct 03, 2021 1:28 am

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

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 view

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


Yes.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

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

Postby goosfancito » Mon Oct 04, 2021 9:58 pm

gracias a ambos tres!
fuunciono el de parametrizar.
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests