PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV Mobile 2024 → Use SQL statements in WinDev Mobile 21
Use SQL statements in WinDev Mobile 21
Iniciado por JAMESGOT, out., 10 2022 6:35 AM - 1 resposta
Membro registado
1 mensagem
Publicado em outubro, 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?
Publicado em outubro, 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