Migrate from DBFCDX TO SQL

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
fouednoomen
Posts: 188
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

Migrate from DBFCDX TO SQL

Post by fouednoomen »

Dear Friends

Can anyone help me to Migrate from DBFCDX to MySql or Sqlite for
my first project (Client)

Please look at attached project build with DBFCDX , i put also the sqlite
database (Mydbase.db) with 2 tables client and reprsen


regards

Foued
Attachments
client.rar
(981.9 KiB) Downloaded 449 times
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Migrate from DBFCDX TO SQL

Post by Rathinagiri »

Hi,

Except "Do Report", I had implemented SQLite version of your code. Please see.
client.zip
(21.14 KiB) Downloaded 414 times
For your kind information, it took 1 hour to modify. :)

If you want to modify this to MySQL, you need not change anything except the connection in main.prg line no 54 and replacement of hmgmysql for hmgsqlite in libs.

Code: Select all

oDB := connect2db( 'localhost', cUserName, cPassword, 'mydatabase' )
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
fouednoomen
Posts: 188
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

Re: Migrate from DBFCDX TO SQL

Post by fouednoomen »

Hi Radhi ,

Many thanks for prompt help it's run like i need ,
I appreciate very much you help because i need to
know how i can start . As when i start with hmg to migrate all my projects from clipper , on the beginning it seems difficult but when some one help me to start it becomes easy day per day .

Best regards

Foued
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Migrate from DBFCDX TO SQL

Post by bpd2000 »

rathinagiri wrote:Hi,

Except "Do Report", I had implemented SQLite version of your code. Please see.
client.zip
For your kind information, it took 1 hour to modify. :)

If you want to modify this to MySQL, you need not change anything except the connection in main.prg line no 54 and replacement of hmgmysql for hmgsqlite in libs.

Code: Select all

oDB := connect2db( 'localhost', cUserName, cPassword, 'mydatabase' )
Thank you, Rathi
Very helpful
BPD
Convert Dream into Reality through HMG
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Migrate from DBFCDX TO SQL

Post by Rathinagiri »

Now I had included 'do report' part also.
client.zip
(156.21 KiB) Downloaded 416 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
fouednoomen
Posts: 188
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

Re: Migrate from DBFCDX TO SQL

Post by fouednoomen »

Hi Radhi

Many thanks for this effort

I'm sure all members of our forum will benefited by this workshop

Also i add a small modification to search client with name or a part of name

*------------------------------------------------------------*
Procedure Find()
*------------------------------------------------------------*
Local Find

Find := Upper (AllTrim(InputBox( 'Code/Raison Client:' , 'Chercher un Client' )))

If .Not. Empty(Find)
aTable := sql( oDB, 'select * from client where cod_cli = ' + c2sql( find ) )
if len( aTable ) > 0
for i := 1 to win_1.browse_1.itemcount
if alltrim( win_1.browse_1.cell( i, 1 ) ) == alltrim( find )
win_1.browse_1.value := i
exit
endif
next i
else
Find:=Find+'%'
aTable := sql( oDB, 'select * from client where raison like ' + c2sql( find ) )
if len( aTable ) > 0

for i := 1 to win_1.browse_1.itemcount
if left(win_1.browse_1.cell( i, 2 ),len(find)-1) == left( find,len(find)-1 )
win_1.browse_1.value := i
exit
endif
next i
else
MsgExclamation('Code Client Enexistant')
endif

endif

endif

Return
*------------------------------------------------------------*

Best regards

Foued
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Migrate from DBFCDX TO SQL

Post by Rathinagiri »

Thank you.

Here I have told about the common pattern of a HMG prg file. That pattern is exactly found here too.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Migrate from DBFCDX TO SQL

Post by bpd2000 »

While compiling following error, what is missing ?

hbmk2: Error: Referenced, missing, but unknown function(s): CONNECT2DB(),
SQL(), C2SQL(), MISCSQL()
BPD
Convert Dream into Reality through HMG
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Migrate from DBFCDX TO SQL

Post by Rathinagiri »

In the project.hbc file you have to add the following line.

libs=hmgsqlite
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Migrate from DBFCDX TO SQL

Post by bpd2000 »

rathinagiri wrote:In the project.hbc file you have to add the following line.

libs=hmgsqlite
Thank you for suggestion
libs=hmgsqlite was in the project.hbc but it worked after inclusion in the hmg.hbc, why ?
BPD
Convert Dream into Reality through HMG
Post Reply