Topic: I am having trouble adding a column to a table

I have just converted to using the SQLitePass package, which is very nice, but I am having trouble adding a column to a table, using the syntax:

SQLStr := Format ('BEGIN TRANSACTION; ALTER TABLE %s ADD COLUMN %s %s; COMMIT;',
                         [LocalDef.Name, RefDef.Name, FieldTypeStr]);
               if (NOT (FieldCreated)) then begin
               TempQuery.SQL.Text := SQLStr;
               TempQuery.Open;
               TempQuery.ApplyChanges;
               TempQuery.Close;                                     

This produces a line such as "... ALTER TABLE PROGRESSION ADD COLUMN Value; ..." which appears to execute without a problem, but when checking the database using another program (I am using the SQLite Manager addon for FireFox/Komodo Edit on Linux) I cannot find the new column in the database.

Not sure what I am doing wrong; is there something I need to do to write out the changes to the database file?

Thanks for the help.

Re: I am having trouble adding a column to a table

Hi Salsan,

To Execute an SQL, you just have to use a TSQLitePassDatabase (SqliteDb in the example), not a TSqlitePassDataset.
Here is an example:

...
SqliteDb.Engine.ExecSQL('CREATE TABLE `PROGRESSION` (FIELD1 INTEGER);');
SqliteDb.Engine.ExecSQL('BEGIN TRANSACTION; ALTER TABLE PROGRESSION ADD COLUMN FIELD2 TEXT(50); COMMIT;');
...

Regards

Re: I am having trouble adding a column to a table

hi salsan you are doing a nice jobs,..
keep it up thanks,..

Re: I am having trouble adding a column to a table

I also have same problem with table but now solved......Thanks lucky .