Hi All
Is there a sample showing how you can access MySQL and process a table using Clipper Commands ?
CCH
http://cch4clipper.blogspot.com
HMG and MySQL
Moderator: Rathinagiri
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: HMG and MySQL
You can find out here about HMG and MySQL.
Here Sudip had created an utility to convert dbf tables to MySQL. It can show you how to use HMG along with MySQL.
Here Sudip had created an utility to convert dbf tables to MySQL. It can show you how to use HMG along with MySQL.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
-
- Posts: 140
- Joined: Tue Mar 03, 2009 8:59 am
Re: HMG and MySQL
Hi Rathinagiri
Thanx for your speedy response and yes, Sudip has been kind enough to send me his codes which is now published at Clipper... Clipper... Clipper. But it is not exactly what I want.
I am trying to convert a Harbour+HMG app to read from MySQL instead of DBFs
This is an extract from ADORDD-2 which works
/*
* MINIGUI - Harbour Win32 GUI library Demo
*
* Copyright 2002-2008 Roberto Lopez <harbourminigui@gmail.com>
* http://harbourminigui.googlepages.com/
*
* To test this sample:
*
* - 'root' at 'localhost' with no password is assumed.
* - 'NAMEBOOK' database and 'NAMES' existence is assumed
* (you may create them using 'demo_2.prg' sample
* at \minigui\samples\basic\mysql)
*
*/
#include "adordd.ch"
#include "minigui.ch"
Function Main()
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 800 HEIGHT 600 ;
TITLE 'MiniGUI MySql Browse Demo' ;
MAIN NOMAXIMIZE
DEFINE MAIN MENU
POPUP 'File'
MENUITEM 'Query' ACTION Query()
SEPARATOR
ITEM "Exit" ACTION ThisWindow.Release()
END POPUP
END MENU
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil
Procedure Query
Local cDatabase := 'FAR4MYSQL' //'NAMEBOOK'
Local cTable := 'FARDAT' //'Names'
Local cServer := 'localhost'
Local cUser := 'root'
Local cPass := ''
Local aFieldNames := {}
Local aHeaders := {}
Local aWidths := {}
Local i
If InputWindow( 'Login' , ;
{'Server' , 'User', 'Password', 'Database', 'Table'} , ;
{cServer , cUser, cPass, cDatabase, cTable } , ;
{ 16 , 16 , 16 , 16 , 16 } ) [1] # Nil
USE (cDataBase) VIA "ADORDD" TABLE cTable MYSQL ;
FROM cServer USER cUser PASSWORD cPass
For i := 1 To FCount()
aadd ( aFieldNames , cDataBase + '->' + FieldName(i) )
aadd ( aHeaders , FieldName(i) )
aadd ( aWidths , 160 )
Next i
DEFINE WINDOW Query ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'MiniGUI ADO RDD Sample' ;
NOMAXIMIZE
@ 10,10 BROWSE Browse_1 ;
WIDTH 610 ;
HEIGHT 390 ;
HEADERS aHeaders ;
WIDTHS aWidths ;
WORKAREA &(cDataBase) ;
FIELDS aFieldNames
END WINDOW
CENTER WINDOW Query
ACTIVATE WINDOW Query
USE
EndIf
Return
What if I need to open multiple tables which I usually accomplish as follows :-
USE (DBF1)
oldarea::=Select()
SELECT 0
USE (DBF2)
SELECT(oldarea)
This does not work
cTable:='DBF1'
USE (cDataBase) VIA "ADORDD" TABLE cTable MYSQL ;
FROM cServer USER cUser PASSWORD cPass
oldArea:=SELECT()
cch: ok
cTable:='DBF2'
USE (cDataBase) VIA "ADORDD" TABLE cTable MYSQL ;
FROM cServer USER cUser PASSWORD cPass
cch: HMG insists that FAR4MYSQL workarea already in use
What is the correct manner to access multiple tables from MySQL using xBase syntax
CCH
http://cch4clipper.blogspot.com
Thanx for your speedy response and yes, Sudip has been kind enough to send me his codes which is now published at Clipper... Clipper... Clipper. But it is not exactly what I want.
I am trying to convert a Harbour+HMG app to read from MySQL instead of DBFs
This is an extract from ADORDD-2 which works
/*
* MINIGUI - Harbour Win32 GUI library Demo
*
* Copyright 2002-2008 Roberto Lopez <harbourminigui@gmail.com>
* http://harbourminigui.googlepages.com/
*
* To test this sample:
*
* - 'root' at 'localhost' with no password is assumed.
* - 'NAMEBOOK' database and 'NAMES' existence is assumed
* (you may create them using 'demo_2.prg' sample
* at \minigui\samples\basic\mysql)
*
*/
#include "adordd.ch"
#include "minigui.ch"
Function Main()
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 800 HEIGHT 600 ;
TITLE 'MiniGUI MySql Browse Demo' ;
MAIN NOMAXIMIZE
DEFINE MAIN MENU
POPUP 'File'
MENUITEM 'Query' ACTION Query()
SEPARATOR
ITEM "Exit" ACTION ThisWindow.Release()
END POPUP
END MENU
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil
Procedure Query
Local cDatabase := 'FAR4MYSQL' //'NAMEBOOK'
Local cTable := 'FARDAT' //'Names'
Local cServer := 'localhost'
Local cUser := 'root'
Local cPass := ''
Local aFieldNames := {}
Local aHeaders := {}
Local aWidths := {}
Local i
If InputWindow( 'Login' , ;
{'Server' , 'User', 'Password', 'Database', 'Table'} , ;
{cServer , cUser, cPass, cDatabase, cTable } , ;
{ 16 , 16 , 16 , 16 , 16 } ) [1] # Nil
USE (cDataBase) VIA "ADORDD" TABLE cTable MYSQL ;
FROM cServer USER cUser PASSWORD cPass
For i := 1 To FCount()
aadd ( aFieldNames , cDataBase + '->' + FieldName(i) )
aadd ( aHeaders , FieldName(i) )
aadd ( aWidths , 160 )
Next i
DEFINE WINDOW Query ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'MiniGUI ADO RDD Sample' ;
NOMAXIMIZE
@ 10,10 BROWSE Browse_1 ;
WIDTH 610 ;
HEIGHT 390 ;
HEADERS aHeaders ;
WIDTHS aWidths ;
WORKAREA &(cDataBase) ;
FIELDS aFieldNames
END WINDOW
CENTER WINDOW Query
ACTIVATE WINDOW Query
USE
EndIf
Return
What if I need to open multiple tables which I usually accomplish as follows :-
USE (DBF1)
oldarea::=Select()
SELECT 0
USE (DBF2)
SELECT(oldarea)
This does not work
cTable:='DBF1'
USE (cDataBase) VIA "ADORDD" TABLE cTable MYSQL ;
FROM cServer USER cUser PASSWORD cPass
oldArea:=SELECT()
cch: ok
cTable:='DBF2'
USE (cDataBase) VIA "ADORDD" TABLE cTable MYSQL ;
FROM cServer USER cUser PASSWORD cPass
cch: HMG insists that FAR4MYSQL workarea already in use
What is the correct manner to access multiple tables from MySQL using xBase syntax
CCH
http://cch4clipper.blogspot.com
Re: HMG and MySQL
Hello CCH,
IMHO, tMySql library is a better choice as long as RDDSQL doesn't have it's full power like updating database with simple xbase commands (and some other points).
For tMySql we have created a very simple project (with help of Rathi) viewtopic.php?f=15&t=297 (Please go to the last page of this topic for latest version of this project)
Regards.
Sudip
IMHO, tMySql library is a better choice as long as RDDSQL doesn't have it's full power like updating database with simple xbase commands (and some other points).
For tMySql we have created a very simple project (with help of Rathi) viewtopic.php?f=15&t=297 (Please go to the last page of this topic for latest version of this project)
Regards.
Sudip
With best regards,
Sudip
Sudip
-
- Posts: 140
- Joined: Tue Mar 03, 2009 8:59 am
Re: HMG and MySQL
Hi All
Solution
=====
Add ALIAS after "ADORDD" and before TABLE
cTable:='DBF1'
USE (cDataBase) VIA "ADORDD" ALIAS "DBF1" TABLE cTable MYSQL ;
FROM cServer USER cUser PASSWORD cPass
oldArea:=SELECT()
cTable:='DBF2'
USE (cDataBase) VIA "ADORDD" ALIAS "DBF1" TABLE cTable MYSQL ;
FROM cServer USER cUser PASSWORD cPass
CCH
http://cch4clipper.blogspot.com
Solution
=====
Add ALIAS after "ADORDD" and before TABLE
cTable:='DBF1'
USE (cDataBase) VIA "ADORDD" ALIAS "DBF1" TABLE cTable MYSQL ;
FROM cServer USER cUser PASSWORD cPass
oldArea:=SELECT()
cTable:='DBF2'
USE (cDataBase) VIA "ADORDD" ALIAS "DBF1" TABLE cTable MYSQL ;
FROM cServer USER cUser PASSWORD cPass
CCH
http://cch4clipper.blogspot.com