SQLite Database with <> # of fields

I have two versions of the data base file and I am actually modify the Export in a Text File Method.

Initially, I used the DB.SQLSelect ("SELECT <list of fields> FROM MyTableName").

To be able to read (or not) the added field, I used:

Foo = RS.Field("Enfant") // Enfant is the name of the Field that exists only in the new data base file If Not CaritasDB.Error Then

And this works fine (only on the newly created SQLite data base file).

When I tried to load an old SQLite data base file, I get a Unknow Field “Enfant” on the DB.SQLSelect ("SELECT <list of fiels> FROM MyDBName") line.

So, I changed the Select line to:

DB.SQLSelect ("SELECT * FROM MyTableName")

But now, I get a Nil in the line (with the old db file, works as expected with the new db file):

Foo = RS.Field("Enfant")

Nota: DB, RS and Foo are correctly declared, not empty nor Nil, I checked in the Debugger. I also delete the contents of the Cache folder.

I’m stuck here: not a single idea to go ahead.

You can use SQLiteDatabase.FieldSchema(TableName) to get a RecordSet with the available columns of a table.

Thank you Tim for your answer. Now I have to implement your suggestion (the hard part).

I tried FieldSchema, but in the debugger I do not found what I wanted, so I (temporary) scrapped that idea.

I drink a glass of fresh water with a cloud of mint and tried a different line:

If CaritasRS.Field("Enfant") <> Nil Then

Removed the Error checking and run: no error, but I do not get my field (err… what I want to do).

After some trying and error, I found a simple way to add the contents of the Enfant field + Tab (if one exists) or add a single Tab (empty column).

To be short and clear: all is OK now.

One more thank to Tim (often a simple answer can lead to the solution or let think to a new idea that lead to a solution). In this case, I merged the two line (far above) into a single one that resolve the problem.