How to Avoid Data Corruption

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
swapan
Posts: 242
Joined: Mon Mar 16, 2009 4:23 am
Location: Kolkata, India
Contact:

Re: How to Avoid Data Corruption

Post by swapan »

rathinagiri wrote:
sudip wrote: I don't know how do you understand exactly what I want?
Because, I had also struggled like you.
This forum is nice because of people like you. Its my honest opinion. Keep it up.
Here I would also like to thank Sudip for insisting me to have a "try" with HMG for fresh projects. Actually no body wants to come out of his/her "confort zone". Its a hinderance in learning a new language. So gradually I'm shedding my "comfort zone" (of Clipper, xHarbour-console mode) and playing with GUI of xHarbour.

Thanks everybody..............

Regards,

Swapan
Thanks & Regards,
Swapan Das

http://www.swapandas.com/
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: How to Avoid Data Corruption

Post by sudip »

Hi,

I can login to MySql and create database, tables from my HMG program. And it's not a "copy-cat programming", I can write the codes of my own. (not a big deal but something is always better than nothing)

Now, I am analyzing the logic of data-entry screen. I have some points in my mind.
1. Using browse is difficult (if not impossible), so grid should be used for browsing data.
2. Skip, go (xxx) will not work, as records are fetched from server and stored in array.
3. A selective part of the table (I can say subset of table) should be fetched from the table in stead of getting all records in a browse control.
4. Main difference between normal dbf table and RDBMS table is that 1st one is record based and 2nd one is set based.

For the above reasons our general way of xbase programming should be modified when we use sql.

Thank you all for such a wonderful "journey". May be I am slow, because of my daily schedule.

With best regards.

Sudip
With best regards,
Sudip
User avatar
gfilatov
Posts: 1084
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: How to Avoid Data Corruption

Post by gfilatov »

sudip wrote:Hi,

I can login to MySql and create database, tables from my HMG program. And it's not a "copy-cat programming", I can write the codes of my own. (not a big deal but something is always better than nothing)

Now, I am analyzing the logic of data-entry screen. I have some points in my mind.
1. Using browse is difficult (if not impossible), so grid should be used for browsing data.
2. Skip, go (xxx) will not work, as records are fetched from server and stored in array.
3. A selective part of the table (I can say subset of table) should be fetched from the table in stead of getting all records in a browse control.
4. Main difference between normal dbf table and RDBMS table is that 1st one is record based and 2nd one is set based.

For the above reasons our general way of xbase programming should be modified when we use sql.
Hi Sudip,

You are right for case when you use the class Tmysqlserver.
But we have a contrib library HbSqlDD (SQL Database Driver) in Harbour SVN.

You will use the MySql database with this library by "old fashion" commands for DBF managing.
Take a look for a small sample below:
/*
* MINIGUI - Harbour Win32 GUI library Demo
*
* Copyright 2002-2008 Roberto Lopez <harbourminigui@gmail.com>
* http://harbourminigui.googlepages.com/
*
* Copyright 2008 Grigory Filatov <gfilatov@freemail.ru>
*
* Based on RDDSQL sample included in Harbour distribution
*/

#include "minigui.ch"
#include "dbinfo.ch"
#include "error.ch"

#define DBI_QUERY 1001

#define RDDI_CONNECT 1001
#define RDDI_DISCONNECT 1002
#define RDDI_EXECUTE 1003
#define RDDI_ERROR 1004
#define RDDI_ERRORNO 1005
#define RDDI_NEWID 1006
#define RDDI_AFFECTEDROWS 1007
#define RDDI_QUERY 1008

ANNOUNCE RDDSYS
REQUEST MYSQLDD, SQLMIX

*--------------------------------------------------------*
Function Main()
*--------------------------------------------------------*

RDDSETDEFAULT( "SQLMIX" )

IF RDDINFO( RDDI_CONNECT, {"MYSQL", "localhost", "root",, "test"} ) == 0
MsgStop("Unable connect to the server!", "Error")
Return nil
ENDIF

DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'MiniGUI SQL Database Driver Demo' ;
MAIN NOMAXIMIZE ;
ON INIT OpenTable() ;
ON RELEASE CloseTable()

DEFINE MAIN MENU

DEFINE POPUP 'Test'
MENUITEM 'Add record' ACTION AddRecord()
SEPARATOR
ITEM "Exit" ACTION ThisWindow.Release()
END POPUP

END MENU

@ 10,10 BROWSE Browse_1 ;
WIDTH 610 ;
HEIGHT 390 ;
HEADERS { 'Code' , 'Name' , 'Residents' } ;
WIDTHS { 50 , 160 , 100 } ;
WORKAREA country ;
FIELDS { 'country->Code' , 'country->Name' , 'country->Residents' } ;
JUSTIFY { BROWSE_JTFY_LEFT, BROWSE_JTFY_LEFT, BROWSE_JTFY_RIGHT }

END WINDOW

CENTER WINDOW Form_1

ACTIVATE WINDOW Form_1

Return nil

*--------------------------------------------------------*
Procedure OpenTable
*--------------------------------------------------------*

If CreateTable()

DBUSEAREA( .T.,, "SELECT * FROM country", "country" )

INDEX ON FIELD->RESIDENTS TAG residents TO country

GO TOP

Else

ReleaseAllWindows()

EndIf

Return

*--------------------------------------------------------*
Procedure CloseTable
*--------------------------------------------------------*

DBCLOSEALL()

Return

*--------------------------------------------------------*
Procedure AddRecord
*--------------------------------------------------------*

APPEND BLANK

REPLACE CODE WITH 'ARG', ;
NAME WITH 'Argentina', ;
RESIDENTS WITH 38740000

GO TOP
Form_1.Browse_1.Refresh

Return

*--------------------------------------------------------*
Function CreateTable
*--------------------------------------------------------*
Local ret := .T.

RDDINFO(RDDI_EXECUTE, "DROP TABLE country")
If RDDINFO(RDDI_EXECUTE, "CREATE TABLE country (CODE char(3), NAME char(50), RESIDENTS int(11))")
If ! RDDINFO(RDDI_EXECUTE, "INSERT INTO country values ('LTU', 'Lithuania', 3369600), ('USA', 'United States of America', 305397000), ('POR', 'Portugal', 10617600), ('POL', 'Poland', 38115967), ('AUS', 'Australia', 21446187), ('FRA', 'France', 64473140), ('RUS', 'Russia', 141900000)")
MsgStop("Can't fill table Country!", "Error")
ret := .F.
EndIf
Else
MsgStop("Can't create table Country!", "Error")
ret := .F.
EndIf

Return ret
I hope that give you an idea :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
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: How to Avoid Data Corruption

Post by Rathinagiri »

Nice explanation Grigory Filatov.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: How to Avoid Data Corruption

Post by sudip »

Hello Grigory,

Thank you very much for helping me to learn MySql with HMG :)

But I couldn't compile the code. It said that It couldn't find MYSQLDD, SQLMIX.

May be I require HbSqlDD. So, from where I can download it and how to use it?

Can you please help me?

With best regards.

Sudip
With best regards,
Sudip
User avatar
gfilatov
Posts: 1084
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: How to Avoid Data Corruption

Post by gfilatov »

sudip wrote:Hello Grigory,
...
May be I require HbSqlDD. So, from where I can download it and how to use it?

Can you please help me?
Hello Sudip,

This library is included in HMG Extended Edition distribution.
Take a look for source at the folder minigui\source\HbSqlDD and sample at the folder minigui\samples\Advanced\MySqlDD.

That's all :!:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
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: How to Avoid Data Corruption

Post by Rathinagiri »

sudip wrote:Hi,

I can login to MySql and create database, tables from my HMG program. And it's not a "copy-cat programming", I can write the codes of my own. (not a big deal but something is always better than nothing)

Now, I am analyzing the logic of data-entry screen. I have some points in my mind.
1. Using browse is difficult (if not impossible), so grid should be used for browsing data.
2. Skip, go (xxx) will not work, as records are fetched from server and stored in array.
3. A selective part of the table (I can say subset of table) should be fetched from the table in stead of getting all records in a browse control.
4. Main difference between normal dbf table and RDBMS table is that 1st one is record based and 2nd one is set based.

For the above reasons our general way of xbase programming should be modified when we use sql.

Thank you all for such a wonderful "journey". May be I am slow, because of my daily schedule.

With best regards.

Sudip
Even though we could not change our existing projects, it can be used for new projects.

IMHO, the usage of browse, skip is not necessary in RDBMS based programming as you had correctly said, here we deal with a record set.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: How to Avoid Data Corruption

Post by Roberto Lopez »

gfilatov wrote: You are right for case when you use the class Tmysqlserver.
But we have a contrib library HbSqlDD (SQL Database Driver) in Harbour SVN.
You will use the MySql database with this library by "old fashion" commands for DBF managing.
Take a look for a small sample below:
>...>
I hope that give you an idea :idea:
I'm sure that this library will replace RDDADO and TMySql definitively (at least, I plan to do it for my own applications).

I'm waiting for the next Harbour 'official' release to include in the distribution.

Regards,

ROberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: How to Avoid Data Corruption

Post by sudip »

Hello Everybody,
Grigory wrote:
Hello Sudip,

This library is included in HMG Extended Edition distribution.
Take a look for source at the folder minigui\source\HbSqlDD and sample at the folder minigui\samples\Advanced\MySqlDD.
Thank you Grigory, I already compiled that sample with MiniGui Ext, but it didn't run. I sent the error log to Minigui Extended Group. Please help me. :)

Hello Rathi,
IMHO, the usage of browse, skip is not necessary in RDBMS based programming as you had correctly said, here we deal with a record set.
I agree with you. :)


Hello Roberto,
I'm sure that this library will replace RDDADO and TMySql definitively (at least, I plan to do it for my own applications).
I'm waiting for the next Harbour 'official' release to include in the distribution.
Great! I shall wait for this! But, I want to learn TMySql first. Because, I have a very bad habit of being "out of focus" ;) My newly found friend CCH tried his best to correct this :)

I have some doubts in my mind.
1. If there any possibility of performance degradation using "browse" with HbSqlDD?
2. Can we use any SQL database with HbSqlDD? If yes, then nothing like it :)
3. Can we perform BEGIN TRANSACTION .... END TRANSACTION .... with HbSqlDD?

In VFP, there are 2 things called "Remote Views" and "Connections". I had very bad experience regarding skipping and browsing records of large tables with "Remote View", I hope (and I am sure) HbSqlDD will be far far better than "Remote View" :)

So, thank you all Gurus.

With best regards.

Sudip
With best regards,
Sudip
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: How to Avoid Data Corruption

Post by Roberto Lopez »

sudip wrote: I have some doubts in my mind.
1. If there any possibility of performance degradation using "browse" with HbSqlDD?
2. Can we use any SQL database with HbSqlDD? If yes, then nothing like it :)
3. Can we perform BEGIN TRANSACTION .... END TRANSACTION .... with HbSqlDD?

In VFP, there are 2 things called "Remote Views" and "Connections". I had very bad experience regarding skipping and browsing records of large tables with "Remote View", I hope (and I am sure) HbSqlDD will be far far better than "Remote View" :)
I've not tested yet (I've read the thread about it in Harbour developers list and took a brief look at the sources) but I guess that the performance depends on the recordset that you use.

The 'easy way' will be always use 'SELECT *...' in your USE command (my preferred way :) ) but maybe, that under certain conditions we must 'refine' our query to obtain acceptable results (Remember: I've not tested yet).

Note: I've had a PAINFUL experience with VFP too :)

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
Post Reply