can someone tell me if it is possible to edit RowSets returned by Database.TableColumns to change the structure of a database table? For example the column type/name? Or is this only possible for RowSets that return the data of a table?
it may be easier to do this using executeSQL and sql commands like ALTER TABLE
you can add or drop columns, but to modify works only with certain databases engines.
Yes, and in particular, for SQLite, ALTER TABLE is quite limited, and the column type has little meaning. Might be useful to know what Martin actually wants to do.
I’ve never used either of those. I only use SelectSQL and ExecuteSQL, and use SQL statements to select or update rows. Where SQLite is concerned, you may want to look at:
To be able to use RowSet.EditRow, the table MUST have a primary key. Then after you do the SELECT statement to get the Rowset, if the RowSet variable name is ‘rs’, you need to call
rs.EditRow
// Update the item information
rs.Column ("Item").StringValue = ItemField.Text ' This line is an example
...
// Update the record in the database
rs.SaveRow
Don’t forget to do the appropriate error checking.
Remember, the table must have a primary key or EditRow won’t work.
As far as I know, you cannot change the column name/definition via EditRow, only the row contents. If you want to change the database schema, you must use ALTER TABLE.
Depends on the database. For sqlite, you can’t change the column directly. To change the name or type, you have to create a temporary table, copy the orginal contents into it, drop the column, add the column back with the new name/type, then copy the contents back and delete the temp table. Other databases are easier, but they’re all different.