PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV Mobile 2024 → WM24 Android -> table lindek to a query
WM24 Android -> table lindek to a query
Iniciado por VEGEboss, jun., 24 2019 1:22 PM - 4 respostas
Membro registado
88 mensagems
Popularité : +2 (2 votes)
Publicado em junho, 24 2019 - 1:22 PM
hello folks

I have a strange problem with a table linked to a query, as you can see in the below image





What is the problem?
If I run in Test Mode ( with [GO] button ) everything goes fine: the table is filled with the query result
But if I deploy the App to my Tablet and try to run… the Table remain empty.

I'm sure that:
A) the file (.FIC) is teh same in the two systems
B) the query runs correctly in both systems

so I can't find the reeason why my table is still empty after the query run… :(

I put this code in the Initialization block of the table object

Htest is boolean

Htest = HExecuteQuery(gIW_Fatturato_Azienda)
Info(HErrorInfo())


and the Herrorinfo() returns an empty string

the BIG problem is: WHY it works in the Simulator and NOT in the Tablet?
is only in my fantasy that the table will be automaticcally filled by the query
result and, in reality, I need to use a [FOR EACH] loop?

thanks for your help (if you need more images from the Table definition, please ask)
Mensagem modificada, junho, 24 2019 - 1:25 PM
Publicado em junho, 24 2019 - 6:50 PM
It works on the simulator because the code in the PC can find the location of the file and connect to it, if your code is unchanged that is why it does not work on the mobile, because the files ARE NOT and will never be in the same location. SO to make it work both on your PC and on the device itself you need to deal with the connection of the files for when you are debugging on the PC and when you are running on the Device itself. using functions like IniOSMode() and IniOSSimulatorMode() to code the logic and to change the connection of the file. otherwise it will never work.
Publicado em junho, 24 2019 - 6:54 PM
by the way, i thought you where in IOS, so that is why i mentioned those functions, but the problem is the same for Android and android has similar functions to be able to deal with the database connection when you are on the PC and in GO MODE and when you are testing the app on the device. Same concept explained before in my last message applies.
Membro registado
88 mensagems
Popularité : +2 (2 votes)
Publicado em junho, 25 2019 - 8:05 AM
thanks WindevCol, your idea is interesting but I can't understand. (and FYI I'm working in Android, now)

the file (.FIC) is deployed with the App in the <DB directory> and I'm sure that data are available because if I add a loop with a simple
Info( query.field )
I can see the correct value of each record

so my question is: if the TABLE object should be differently linked to the query… HOW can I do it?
Changing the property at Runtime? mmm what a strange approach!
Publicado em junho, 25 2019 - 2:49 PM
Strange is not, because like you said in Android the database file is on the DB directory of Android, and in your PC is not. and the FILE has been configure to work locally on the path that is on the PC. (and not on the path that will end up in android, they are not the same thing). by the way if you are using HFSQL a file = table = database.
HFSQL has 1 file per table, is not like SQL like and other databases where you only have 1 file. you also need to make sure the database file is where is suppose to be (when installing the application not always gets the file extracted where is suppose to be)so if its not there you should extract it. here is an idea how you could do it with an SQLITE database:

// Name of the SQLite database
sNameSQLiteDatabase is string = "MyDatabase.db"

// In any case, the database is in SQLite format (NOTE: EagleSQLite is the name of your connection)
EagleSQLite..Provider = hNativeAccessSQLite

// Execution on the Android device? Here is executing either on the PC simulator or the Device itself
IF InAndroidMode() = True THEN
// yes
// WINDEV Mobile simulator?
IF InSimulatorMode() = True THEN
// Database in the Exe directory of the project
EagleSQLite..Source = fExeDir() + ["\"] + sNameSQLiteDatabase
ELSE
//We are not on the simulator but on the Mobile device
//If the files does not exists on the data directory of the device we extract the file there
IF fFileExist(CompleteDir(fDataDir()) + sNameSQLiteDatabase) = False THEN
fExtractResource(sNameSQLiteDatabase, CompleteDir(fDataDir()) + sNameSQLiteDatabase)
END
//Setting the connection property to the database directory for android
EagleSQLite..Source = CompleteDir(fDataDir()) + sNameSQLiteDatabase
END

END

Doing something like that will ensure your data connection will never fail on your PC and on the device itself because you are making sure the database file is where is suppose to be both in the PC and on the Device itself, and as you can see is not complicated at all. then you use that connection for whatever you need