PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV Mobile 2024 → Use SQL statements in WinDev Mobile 21
Use SQL statements in WinDev Mobile 21
Iniciado por JAMESGOT, 10,oct. 2022 06:35 - 1 respuesta
Miembro registrado
1 mensaje
Publicado el 10,octubre 2022 - 06:35
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 el 10,octubre 2022 - 11:15
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