Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 3 Jahren, 4 Monaten
Letzter Beitrag:
vor 3 Jahren, 3 Monaten
Beteiligte Autoren:
Yogi Yang, Arie, Fabrice Harari

WM17 - Import data from remote DB to Android App DB

Startbeitrag von Yogi Yang am 20.02.2015 13:27

Hello All,

I am trying to import data from a remote DB which is MySQL and I am using the web service Php2WM.

I am able to get the data from remote MySQL server and insert the same in Android App's DB.

But the problem is that when the data imported the Rec ID are not getting imported as per original data on remote MySQL DB. They are being assigned automatically as the Android Apps DB.

How can I import the data as it is from remote MySQL as it is?


Yogi Yang



if you are using a local HF DB
if you are talking about automatic ID
If you are adding your records using hAdd
then you can for the value of the autoID by using the appropriate parameter in hadd (hforceautoID, from the top of my head)... All details, as usual, are in the help

Best regards

von Fabrice Harari - am 20.02.2015 13:40

Thanks for the hint. Actually from the docs I understood that we have to use hSetIdAuto. And I was using that so I was not getting the expected results.

After using hForceIdAuto things are working as expected.

Once again thanks.


Yogi Yang

von Yogi Yang - am 20.02.2015 14:36
Now I am facing speed problems while importing data.

What I am doing it first deleting all the data in the file in question and then read data from remote server and add the data again. There are approx 59K entries.

Here is the code that I am using:

sSQL is string
bRetCode is boolean

//Delete existing records in Std Master
IF HNbRec(student_master) > 0 THEN
WHILE HNbRec(student_master) > 0
END //WHILE HNbRec(student_master) > 0
END //IF HNbRec(student_master) > 0 THEN

sSQL = "SELECT * FROM student_master"
//Execute SQLAssociebRetCode = AccessMySQL.mySQLExec(SQL, 0)
bRetCode = AccessMySQL.mySQLExec(sSQL, 0)

//If true then success
IF bRetCode = True THEN
//Check number of Rows
IF AccessMySQL.mySQLGetNumRows(0) > 0 THEN
//Move to First Record
//Process All Records
WHILE (NOT AccessMySQL.mySQLEnDehors)
student_master.sm_id = AccessMySQL.mySQLCol(0,1)
student_master.sm_roll_no = AccessMySQL.mySQLCol(0,2)
student_master.sm_fname = AccessMySQL.mySQLCol(0,3)
student_master.sm_mname = AccessMySQL.mySQLCol(0,4)
student_master.sm_lname = AccessMySQL.mySQLCol(0,5)
student_master.sm_address = AccessMySQL.mySQLCol(0,6)
student_master.sm_city = AccessMySQL.mySQLCol(0,7)
student_master.sm_pincode = AccessMySQL.mySQLCol(0,8)
student_master.sm_state = AccessMySQL.mySQLCol(0,9)
student_master.sm_mob_no = AccessMySQL.mySQLCol(0,10)
student_master.sm_email_id = AccessMySQL.mySQLCol(0,11)
student_master.sm_dob = AccessMySQL.mySQLCol(0,12)
student_master.sm_gender = AccessMySQL.mySQLCol(0,13)
student_master.sm_photo = AccessMySQL.mySQLCol(0,14)
student_master.sm_father_name = AccessMySQL.mySQLCol(0,15)
student_master.sm_father_mob_no = AccessMySQL.mySQLCol(0,16)
student_master.sm_father_email_id = AccessMySQL.mySQLCol(0,17)
//Move to Next Record
END //WHILE (NOT AccessMySQL.mySQLEnDehors)
END //IF AccessMySQL.mySQLGetNumRows(0) > 0 THEN
END //IF bRetCode = True THEN

Is there any better way of updating data on the phone instead of first deleting the data and then adding it again.


Yogi Yang

von Yogi Yang - am 20.02.2015 15:22
Hi again

you can use hcreation to delete the whole file and recreating it empty in one line and very fast
After that, you still need to add the records. You can try to deactivate the index creation and deactivate the integrity management in order to gain speed than to a hreindex, that should give your SOME gain...

Best regards

von Fabrice Harari - am 20.02.2015 18:10
try to wrap your loop in a transaction


Otherwise every HAdd() is a transaciton by itself by default. Which causes a lot of overhead.

I had the same problems some years ago. I finally switched to another approach and generate my data on a webserver now (which I used anyway). This is as fast as you may expect and afterwards I download the sqlite.db as a whole.

I'm not sure if this i working in wm17, please give it a try. I'm writing this from memory and left wm17 already 2 years ago for wm18 and wm19 nowadays.

von Arie - am 20.02.2015 19:56
Another thing I found out is refreshing the screen can cost time.
I remember showing a progressbar and incremented is on every record.(10000+).
That costs more time than the actual HAdd !!
Now I increment such progressbar only on every xxx iteration.

von Arie - am 20.02.2015 19:59
try to wrap your loop in a transaction


This feature is not supported in WM17.

There has to be something parallel. I am trying to find that at the moment.


Yogi Yang

von Yogi Yang - am 26.02.2015 06:11
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.