FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Tema maria_Connect / FWCONNECT
Posts: 1078
Joined: Thu Sep 27, 2007 03:47 PM
Tema maria_Connect / FWCONNECT
Posted: Mon Dec 16, 2019 08:48 PM

Saludos al forum
Alquien por casualidad tiene toda la documentacion con el uso de cada uno de los Metodos.

Como hago una busqueda de un registro especifico de un query. Algun Ejemplo

Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Tema maria_Connect / FWCONNECT
Posted: Mon Dec 16, 2019 09:49 PM
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1078
Joined: Thu Sep 27, 2007 03:47 PM
Re: Tema maria_Connect / FWCONNECT
Posted: Mon Dec 16, 2019 10:29 PM
Gracias. por tu informacion,
Segun el ejemplo cual es la diferencia entre oCn:RowSet(.... y oCn:Query( ... segun veo funcionan igual , cual seria lo recomendable para el uso de cada uno.

oRs := oCn:RowSet( cTableNameOrcSqlStatement, [aParams], [lShowError] )
or
oQry := oCn:Query( cTableNameOrcSqlStatement, [aParams], [lShowError] )


oRs:SetFilter( filterexpression_with_dbfsyntax )
oRs:Filter := <newfilter>
Si uso SetFilter de esta manera no me funciona.
oDbf:SetFilter( variable='1' )
no me funciona, que error estoy cometiendo, no me funciona


Si tengo un Query y necesito buscar un registro especifico se usaria SetFilter , porque no genera un nuevo Query no se si me equivoco, Funciona igual cuando uno usa ADO (Tiene esta funciones para hacer busquedas y no genera un nuevo Query o Estancia como Find , Filter, Seek .

Tu sabes como se llama la clase de FWH no se si esta el fuente.

Lastima que exista ejemplos asi como tdolphin que se puedan reproducir.
Gracias
Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Tema maria_Connect / FWCONNECT
Posted: Wed Dec 18, 2019 08:36 AM
Code (fw): Select all Collapse
oDbf:Filter := "variable = 'abc'" // exactly like ADO
// OR
oDbf:SetFilter( "variable='abc'" )


With both ADO and FWH, the filter is set within the memory and does not read again from the server.
for filter expressions, use the familiar DBF syntax.

We can use parameters also.
Code (fw): Select all Collapse
local nAge, cState

nAge := 40
cState := "NY"
oRs:SetFilter( "state = ? .and. age >= ?", { cState, nAge } )
// ....
// later
// ....
cState := "WA"
nAge := 50
oRs:ReFilter( { cState, nAge } )


Works even if the connection to server is lost.

SEEK:

oRs:Sort := <fieldname>
// OR
oRs:SetOrder( <fieldname> )

oRs:Seek( <value>, [lSoft], [lWild] ) --> lSuccess
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Tema maria_Connect / FWCONNECT
Posted: Wed Dec 18, 2019 08:48 AM

Please see

viewtopic.php?f=3t=33286

You can read the complete documentation.

References to WIKI are also given here

&

Regards



G. N. Rao.

Hyderabad, India
Posts: 1078
Joined: Thu Sep 27, 2007 03:47 PM
Re: Tema maria_Connect / FWCONNECT
Posted: Wed Dec 18, 2019 04:08 PM

Gracias G. N. Rao.

Te cuento no me funciona. Ni con seek ni setfilter o locate. No busca el registro
Lo hago asi
oDbf:SetFilter( xfind )
if oDbf:EOF()
fiarc := 0
endif

Pero usando ADO si funciona,

Te pregunto que libreria se requiere para usar este recurso.

Solamente Adicione libmysql.lib, tambien Adicione libmariadb.lib

Por curiosidad he visto una libreria mysqlclient.lib tu sabes como se usa.

Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Tema maria_Connect / FWCONNECT
Posted: Wed Dec 18, 2019 05:08 PM

I tell you it doesn't work for me. Neither with seek nor setfilter or locate. It does not search the registry.
I do it like this
oDbf: SetFilter (xfind)
if oDbf: EOF ()
fiarc: = 0
endif


I will post some working samples in my next post.


I ask you what library is required to use this resource.

Just add libmysql.lib, also add libmariadb.lib


Whether you use MySql (version 5.x) server or MariaDB server, we can use either libmysql.lib or libmariadb.lib. Both work the same way. But if we link with libmysql.lib we have to keeplibmysql.dll or if we link with libmariadb.lib, we need to keep libmariadb.dll in the exe path.

But if you use MySql server 8.0 onwards please see this post:
viewtopic.php?f=6&t=38134


Out of curiosity I have seen a mysqlclient.lib library you know how it is used.


If we link mysqlclient.lib with our application, we need not use any DLL like libmysql.dll. But the size of our exe will be very large.

BUT
This lib is built with Microsoft Visual Studio and our application needs to be built with the same version of Microsoft Visual studio as the version used my MySQL to build the library.

So that is not an option for us.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Tema maria_Connect / FWCONNECT
Posted: Sun Dec 22, 2019 04:55 AM
Small test program to test how filters work.
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local oCn, oRs

   oCn   := FW_DemoDB()

   oRs   := oCn:RowSet( "SELECT FIRST,STATE,AGE,SALARY FROM customer" )

   oCn:Close() // Let us close connection and see if filters still work

   XBROWSER oRs SHOW SLNUM TITLE "CUSTOMER : NO FILTER"

   oRs:SetFilter( "UPPER( ? ) $ UPPER(FIRST) .AND. STATE = ? .AND. AGE > ?", { "en", "NY", 30 } )
   oRs:GoTop()
   XBROWSER oRs SHOW SLNUM TITLE "CUSTOMER : " + oRs:cFilterExp

   oRs:ReFilter( { "o", "WA", 40 } )
   oRs:GoTop()
   XBROWSER oRs SHOW SLNUM TITLE "CUSTOMER : " + oRs:cFilterExp

return nil






Regards



G. N. Rao.

Hyderabad, India

Continue the discussion