Table name

This is probably SO simple I am going to kick myself, but I can’t get this to work.

I want to find out the name of a table within a database. Simple huh?

Well I use the line (for testing only)

MessageBox "The table name is : " + db.Tables

And I get the message "Can't use the operand + ..."

Having gone to the sqlite information, when you connect to a database, and then go tables, you get the table name, no problem. In fact databases with more than one table gives you all of them.

But I can’t pull the name no matter what I try.
Any ideas to push me in the right direction???

Regards

The documentation on SQLiteDatabase.Tables would be a great place to start. It will tell you what type that function returns. It’s not a string, that’s why you’re getting the error.

https://documentation.xojo.com/api/databases/sqlitedatabase.html#sqlitedatabase-tables

Database.Tables is a Rowset, so you’ll need to iterate through it to get a list of tables in the database.

Thanks.

My error. When I looked at the docs I understood (incorrectly) that a single row was returned with the table name.

Regards

Thanks Wayne.

Tim told me what my misunderstanding was.

I’m going to try things his way (and believe it or not I did have my tableVariable as a rowset.)

Regards

I believe in trying to help people learn how to solve problems for themselves, so sometimes I’m a little bit vague. If it’s not sufficient or you need more help please don’t hesitate to ask.

There is example code in the docs that should show you how this operates (by fetching the StringValue from a Column in the RowSet.)

2 Likes

tim your help is always appreciated… actually ALL help is appreciated. My problems (usually caused by ME) come from not having the correct thinking pattern in the old grey matter.

Once again, thank you ALL for your help.