PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio â†’ WINDEV 2024 â†’ [WM18] How to modify data structure in Android?
[WM18] How to modify data structure in Android?
Iniciado por guest, 25,may. 2015 14:05 - 13 respuestas
Publicado el 25,mayo 2015 - 14:05
Hi all,

I am learning Windev Mobile and currently playing around with the Android order management sample. There I changed the description of one data file, which is defined as "HyperFileFSQL Classic" in the analysis.

WM does not seem to be able to modify the file structures automatically like in Windev with HFSQL files, so, when I am launching the test "Go", I get an error stating
"Unable to create the data files native SQLite error. Error Number = 20" ...etc.

When I check the app's exe directory, the files actually seem to be in some ".db" file, which obviously is a SQLite database? There are no .FIC files in this directory.

Tutorial says that the data modifications can be done using replication? Online help says, that replication is available from version 19 on...(my WM is 18). Is this correct also for the structure changes of the files?

1. How can I manage the data structure modifications (changes in analysis) in an Android device using SQLite db?

2. Would it be possible to use HFSQL instead of SQLite in Android? How?

3. What would be the advantages and disadvantages between SQLite and HFSQL in Android?

Best regards
Ola
Publicado el 25,mayo 2015 - 14:46
Hi Ola

first, you need to upgrade your windev mobile... There are so many changes in OS and functionsthat you need to keep curent if you don't want to just waste your time

second, automatic data structure modification is available for HF only, no matter if you are using WD, WB or WM... If you do use HFSQL (declare the files as HF classic in your analysis), then use hmodifyStructure in your code to update your files

As for your questions:
1. the same way you would manage a change of structure in MYSQL or MSSQL... You have to code it (alter table, or create a new table and transfer data)

2. Yes, delcare them as HF in the analysis

3. SQLite works on all android version, HF needs at least version 3.2 (from the top of my head)... HF supports automatic modification

Best regards
Publicado el 25,mayo 2015 - 23:15
Hi Fabrice

Thank you.

best regards
Ola
Publicado el 26,mayo 2015 - 06:00
Quote
Fabrice Harari

2. Yes, delcare them as HF in the analysis
In which version of WM is HF supported in Android?

I am using WM17 and whenever I try to create a file in HF I get a warning from WM17.

TIA

Yogi Yang
Publicado el 26,mayo 2015 - 10:35
Hi Yogi.

WM18 support HF on Android.
Publicado el 26,mayo 2015 - 10:47
Fabrice (et al),

One question more about hModifyStructure:

1. Is it Ok to just run hmodifyStructure routinely in the initialization of the program, regardles whether there has been changes in the analysis or not?

2. Does it not slow down the starting of the program if run unnecessarily?

3 How can I check, whether the analysis has changed compared to the database or not?

Best regards
Ola
Publicado el 26,mayo 2015 - 11:07
Hi Ola

1.
a) For mobile: I make connection first and create button to start hmodifystructure()
b) For PC: I start application with parameter /update to start hmodifystructure(). Without parameter application don't start this function.

2. Yes. It slowing down start of application

This is my experience with hmodifystructure()
Publicado el 26,mayo 2015 - 14:52
Hi Ola

1. in my experience, yes, as it is rare to have more than a few files for a mobile application

2. of course it does, but the amount of time needed to compare version is negligible for 10 or 20 files

3. It doesn't matter, as it is exactly what hmodifystrcuture is doing for you, when there is nothing to modify

Personally, I juts have a hmodifystrcuture in the init of any mobile project

Best regards
Miembro registrado
123 mensajes
Publicado el 26,mayo 2015 - 20:37
If SQLite You can use this before the main connection
ctConn is Connection
ctConn..Source = fDataDir + "/" + "pegasuspedidosmob.db"
ctConn..Provider = hNativeAccessSQLite
ctConn..User = ""
ctConn..Password = ""
ctConn..Server = fDataDir + "/" + "pegasuspedidosmob.db"
ctConn..Database = ""
ctConn..Access = hOReadWrite
IF HOpenConnection(ctConn) = False THEN
Error("Imposible Realizar la Conexión", HErrorInfo(hErrMessage))
EndProgram(True)
END

IF HChangeConnection("*",ctConn) = False THEN
Error("Imposible Seleccionar la Conexión Auxiliar", HErrorInfo(hErrMessage))
EndProgram(True)
FIN

sql is string
query is Data Source

sql="alter table pmob_parametros add direccion_local varchar(200)"

// ALter table in this version..
IF NOT HExecuteSQLQuery(query,sql) THEN
Error("Error al Modificar la Base de Datos Local"+RC+HErrorInfo())
HCloseConnection(ctConn)
RETURN
END
HCloseConnection(ctConn)


--
Atte. Willian Fernando
Best Regards Willian Fernando
Publicado el 27,mayo 2015 - 11:21
Hi ICI, Fabrice,

I am now a bit wiser, thank you.

In my WD ERP I have used WDModfic and started it with a parameter in the ERP's program call.

Best regards
Ola
Publicado el 27,mayo 2015 - 16:12
Hi Ola,

take care, afaik HModifyStructure() only updates the structure of files, NOT the links between the files !
Publicado el 27,mayo 2015 - 21:16
Hi Stefan,

Thanks for the heads-up.

So the next question: how do I update the links, if necessary?

Best regards
Ola
Publicado el 28,mayo 2015 - 15:45
Ola,

Perhaps remove with HDeleteLink and then re-add with HAddLink?
Publicado el 29,mayo 2015 - 13:19
Thank Darren,

Seems to be just another "half-baked" Windev-feature this HModifyStructure()!
Maybe it would be better to define the links from the very start of the app with those link-commands...

best regards
Ola