PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → WDM21 - Write to SQLite DB on android
WDM21 - Write to SQLite DB on android
Débuté par Elisha Spicer, 23 jan. 2018 22:23 - 6 réponses
Posté le 23 janvier 2018 - 22:23
i am in the process of writing my first app with WDM21, it is a barcode scanner for our inventory and tracking. i have successfully been able to get my barcode scanner to retrieve the correct information and display it on screen.

the issue im having relates to writing information to the same (local) database.

i have a couple fields i need to put information about the scanned item.

i have attempted to use an insert query to push the information entered to a new line in one of the tables in the database. however i am not getting anything saved to it.

i have been scouring the tutorial pdf and the doc.windev.com help pages but am running into a wall.
Posté le 23 janvier 2018 - 22:45
Hi

1. you should use HFSQL instead of sql lite, as this will allow you to easily change the DB structure when needed (see help of hmodifystructure)

2. Just do:
hreset(File) File.Field1=value1 File.Field2=value2 if hadd(File)=false then info(herrorinfo(herrfulldetails)) end
This way, either it works and the problem is solved, or you have an error message you can post here

Best regards
Posté le 24 janvier 2018 - 00:07
Ok, i do have a question.

we run SqlServer 2016 on our server, will we have issues importing hfsql into it?

the reason we were trying to go with sqlite, we are under the impression that it is more compatible with sqlserver to import the data?
Posté le 24 janvier 2018 - 13:02
Hi Elisha,

neither is 'compatible' with MSSQL (whatever that would mean) and it's not a problem in either case as:
- you cannot read/write DIRECTLY in MSSQL from android (no driver/odbc or anything of the kind)
- you therefore HAVE TO use a webservice or replication system to read/write in any central DB (except HFSQL server, where pcsoft is providing a driver)
- by experience, you do NOT WANT to directly read/write in a central DB from a mobile, anyway, because the connection is going to be lost many times, and that is baaaad when you are trying to directly access data...

As an aside, I wrote a replication system compatible with android, iOS, and ANY Server side DB engine where PCSoft is providing a direct access module (ie where hadd/hmodify/hdelete is available), it's called WXReplication, is open source and available on my web site.

Even if you are not interested in the replicaton part, you can use its source as an example of REST type webservice...

Best regards
Posté le 24 janvier 2018 - 22:04
Excellent, thank you for clearing that up for me. i will attempt to go with hfsql and the suggestions you posted, i will get back with the results!
Posté le 25 janvier 2018 - 07:56
I used your suggestion, and it works!! no errors and the data is (aparently) being pushed to the hfsql database on my android device.

Thank You very much!
Posté le 27 janvier 2018 - 07:12
Well, the boss tells me that using the database is a no go on the phone.

Im told i have to make it work with our remote sql server database.