PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV Mobile 2024 → Use SQL statements in WinDev Mobile 21
Use SQL statements in WinDev Mobile 21
Started by JAMESGOT, Oct., 10 2022 6:35 AM - 1 reply
Registered member
1 message
Posted on October, 10 2022 - 6:35 AM
I'm developing an Android app with a SQLite database in WM21 but I can't find the way to execute SQL statements like ALTER TABLE.

Query editor don't suport this kind of statements, function HExecuteSQLQuery() declares this query to the HFSQL engine and fails, and SQLExec() doesn't work because SQLConnect() isn't avaliable in Android.

Exists any way to do this with WM21?
Posted on October, 10 2022 - 11:15 AM
Hi JamesGot,


ctDB is Connection
sSQL is string
bModify is boolean
dsChange is Data Source
bOpen is boolean

ctDB..Provider = hNativeAccessSQLite
ctDB..Access = hOReadWrite
ctDB..Source = fDataDir + [fSep] + "Your.db"
ctDB..Server = fDataDir + [fSep] + "Your.db"
// user, pwd, etc

IF HOpenConnection(ctDB) THEN
IF HChangeConnection("*",ctDB) THEN
bOpen=True
ELSE
Error("Fiddle database"+RC+HErrorInfo())
END
ELSE
Error("Open database"+RC+HErrorInfo(hErrFullDetails))
END

IF bOpen THEN
sSQL = "ALTER TABLE tablename ADD NewField FieldType"
IF NOT HExecuteSQLQuery(dsChange,ctDB,hQueryWithoutCorrection, sSQL) THEN
Error(HErrorInfo())
END
END


Hope this helps,
MerijnW