Page 1 of 4

Migrate from DBFCDX TO SQL

Posted: Sun May 19, 2013 11:01 am
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

Re: Migrate from DBFCDX TO SQL

Posted: Sun May 19, 2013 4:04 pm
by Rathinagiri
Hi,

Except "Do Report", I had implemented SQLite version of your code. Please see.
client.zip
(21.14 KiB) Downloaded 426 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' )

Re: Migrate from DBFCDX TO SQL

Posted: Sun May 19, 2013 5:03 pm
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

Re: Migrate from DBFCDX TO SQL

Posted: Sun May 19, 2013 6:09 pm
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

Re: Migrate from DBFCDX TO SQL

Posted: Sun May 19, 2013 7:55 pm
by Rathinagiri
Now I had included 'do report' part also.
client.zip
(156.21 KiB) Downloaded 439 times

Re: Migrate from DBFCDX TO SQL

Posted: Sun May 19, 2013 8:18 pm
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

Re: Migrate from DBFCDX TO SQL

Posted: Mon May 20, 2013 4:07 am
by Rathinagiri
Thank you.

Here I have told about the common pattern of a HMG prg file. That pattern is exactly found here too.

Re: Migrate from DBFCDX TO SQL

Posted: Mon May 20, 2013 4:34 am
by bpd2000
While compiling following error, what is missing ?

hbmk2: Error: Referenced, missing, but unknown function(s): CONNECT2DB(),
SQL(), C2SQL(), MISCSQL()

Re: Migrate from DBFCDX TO SQL

Posted: Mon May 20, 2013 6:30 am
by Rathinagiri
In the project.hbc file you have to add the following line.

libs=hmgsqlite

Re: Migrate from DBFCDX TO SQL

Posted: Mon May 20, 2013 10:23 am
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 ?