[Gambas-user] Sqlite, Delete field from table
Benoît Minisini
gambas at ...1...
Mon Oct 19 17:55:32 CEST 2015
Le 19/10/2015 17:38, Johny Provoost a écrit :
> Hallo,
>
> Is it possible to delete a field in a table from a SQLite database
> through gambas code?
>
> with
> FMain.tmpSQL = "ALTER TABLE " & FMain.lstTables.Text & " ADD " &
> FieldNew.txtFieldname.Text & " " & FieldNew.cmbFieldType.Text
> FMain.openSQL = FMain.$hConnLocl.EXEC(FMain.tmpSQL)
>
> I can add a new field, but if I replace " ADD " with DEL or DELETE, I
> get errors. I search the internet, but found nothing to delete directly
> the field.
>
> There's always a workaround through create tmp table, copy the fields to
> save to it, delete the old table and rename the tmp table back to old
> table. But if it is can be done directly it is much easier.
>
If you can do that with a sqlite SQL request, then you can do that with
Gambas and the Exec() method.
Then it's just a matter of reading the sqlite documentation:
https://sqlite.org/lang_altertable.html
Apparently you can't remove a field with just a SQL request. You have to
follow your workaround as detailed in the SQLite documentation.
Regards,
--
Benoît Minisini
More information about the User
mailing list