Error 1064 xBrowse MySQL

Post Reply
User avatar
ip_ram
Posts: 43
Joined: Tue Nov 21, 2006 4:07 pm
Location: Brazil / MG / Belo Horizonte

Error 1064 xBrowse MySQL

Post by ip_ram »

Olá!

Estou recebendo o erro 1064 (figura) no xBrowse ao consultar uma tabela em MySQL na Internet.

//
// conectar

FWConnect oDba Host cServer User cUsrAdm PassWord cPasAdm DB cDtaBas

If oDba == Nil
oDba:ShowError()
MsgAlert("Não foi possível acessar o BD da aplicação","Atenção")
Return(.f.)
EndIf

oDba:SelectDB(cDtaBas)
oDba:lShowErrors(.t.)
oDba:SetAutoCommit(.t.)

...
...

// criar sql

oPes := oDba:RowSet( "select id as 'ID',nom_pes as 'Nome',ape_pes as 'Apelido'," +;
"ema_pes as 'E-mail',concat('(',substring(tel_pes,1,2),')',"+;
"substring(tel_pes,3,4),'-',substring(tel_pes,7,4)) " +;
"as 'Telefone',concat('(',substring(cel_pes,1,2),')'," +;
"substring(cel_pes,3,5),'-',substring(cel_pes,8,4)) as 'Celular' " +;
"from tb_pes order by nom_pes", .t. )

If oPes == Nil
Return(Nil)
EndIf

...
...

// xbrowse

@ 4.3,00 xBrowse oPesBrw Of oPesWnd ;
DataSource oPes ;
On DblClick(lNew:=.f.,PessoaIncluir()) ;
Font oFnt1 NoBorder Cell ;
UpDate AutoSort
...
Image
...

Após navegar entre os registros e tentar recuperar um deles para edição a mensagem é apresentada.

Alguma dica?

Obrigado!

Rodrigo Melo
Brasil
FW-18.02 / xH / BCC-7.3
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Error 1064 xBrowse MySQL

Post by nageswaragunupudi »

1) Can not see the image.
2) Please ensure that you did not use single quotes where you should have used back-ticks
Regards

G. N. Rao.
Hyderabad, India
User avatar
ip_ram
Posts: 43
Joined: Tue Nov 21, 2006 4:07 pm
Location: Brazil / MG / Belo Horizonte

Re: Error 1064 xBrowse MySQL

Post by ip_ram »

User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Error 1064 xBrowse MySQL

Post by nageswaragunupudi »

Thanks for the image. The error pertains to opening of table `tb_pac`. This is not the table referred to in the main Sql statement.

I am assuming that you are getting the error when you double-click on a row for edit.

This must be relating to the function "PessoaIncluir()". May we see what is in that function? Are you trying to open able tb_pac in that function?
Regards

G. N. Rao.
Hyderabad, India
User avatar
ip_ram
Posts: 43
Joined: Tue Nov 21, 2006 4:07 pm
Location: Brazil / MG / Belo Horizonte

Re: Error 1064 xBrowse MySQL

Post by ip_ram »

This error is shown not only when I try to access the tb_pac table ...

Is there a difference between the Query () and RowSet () commands to display data in the xBrowse?

I was able to retrieve the data and display it as it is in the code and now the error message is constant ... MySQL is in a provider.

Any tips?

Tks!

Rodrigo Melo
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Error 1064 xBrowse MySQL

Post by nageswaragunupudi »

Query() and RowSet() are two names of the same method.
Call to method Query() is translated as call to method RowSet().

This error can happen if the connection's multistatement capability is turned off either by the programmer explicitly by setting
oCn:SetMultiStatement( .f. ) or a similar statement.
This should not be done by the programmer.

I assume you may be not be turning it off in your program.

There is another reason the setting may be turned off automatically without our knowledge. FW library provides automatic-reconnection, if the connection is lost for some reason during runtime. This happens when internet/physical connection to the server goes off and on or connection is lost due to time out. After reconnection, the mulistatement setting is not being restored. (Note: This is fixed in FWH 18.06)

In the absence of full knowledge of your program and database, I am wondering what could be the reason in your case.
Can you react to the above?
Regards

G. N. Rao.
Hyderabad, India
User avatar
ip_ram
Posts: 43
Joined: Tue Nov 21, 2006 4:07 pm
Location: Brazil / MG / Belo Horizonte

Re: Error 1064 xBrowse MySQL (solved)

Post by ip_ram »

Dear Rao,

I checked in the programs that I was closing the connection to the database when closing the Query () object at the end of xBrowse.

...
...

cSql := "select pac.id as 'ID',emp.nom_emp as 'Empresa',"+;
"pac.tit_pac as 'Destino',substr(pac.des_pac,1,50) as 'Detalhes' "+;
"from tb_pac as pac,tb_emp as emp where pac.id_emp = emp.id")

oPac := oDba:Query(cSql)

If oPac == Nil
Return(Nil)
EndIf

Define Window oPacWnd Title "Pacotes" MDIChild Of oWnd From 0,0 To MaxRow(),MaxCol() NoSysMenu
Define ButtonBar oPacBar Top Size 60,60 2007 3D Of oPacWnd

Define Button Of oPacBar NoBorder Resource "ref32" Prompt "Atualizar" ;
Action(oPac:ReQuery(),oPacBrw:SetFocus()) ToolTip "Atualizar lista"
...
Define Button Of oPacBar NoBorder Resource "sair32" Prompt "Fechar" BTNRight Group ;
Action(oPac:Close(),oPacWnd:End()) ToolTip "Fechar"
...
...
Anyway, one more lesson learned.

Thank you!

Rodrigo Melo
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Error 1064 xBrowse MySQL

Post by nageswaragunupudi »

I was closing the connection to the database when closing the Query () object at the end of xBrowse
Please open the connection when you start the application and close the connection only when you end the application. Do not close in between.

Actually, you need not even close the connection, unlike with other libraries. FWH MariaLib automatically closes the connection properly on its own when the application exits. So you need never call oCn:Close() explicitly in your program.
Regards

G. N. Rao.
Hyderabad, India
User avatar
ip_ram
Posts: 43
Joined: Tue Nov 21, 2006 4:07 pm
Location: Brazil / MG / Belo Horizonte

Re: Error 1064 xBrowse MySQL

Post by ip_ram »

Dear Rao,

I thought using:
oPes := oDba:Query('select * from tb_pes')

It would be creating a connection of oDba and, with this, could be closed (oPes:Close()) without also closing the oDba connection (oDba:Close()).

And actually, oPes is an object with the result of Query ...

This understanding generated the error reported above.

Thank you for your support!

Best regards!

Rodrigo Melo
Post Reply