Createtable on starter, everytime that the program loads create a Table? Or if the table is allready create, nothing will happen? I mean, data remains the same. I mean, i will not droptable each load.
Is there any option to see what tables are inside my database?
Cursor1 = SQL1.ExecQuery("SELECT name FROM sqlite_master WHERE type='table'")
For i=0 To Cursor1.RowCount-1
Cursor1.Position=i
Log($"Table: ${i} ${Cursor1.GetString("name")}"$) 'displays all tables in database
Next
Cursor1 = SQL1.ExecQuery("SELECT name FROM sqlite_master WHERE type='table'")
For i=0 To Cursor1.RowCount-1
Cursor1.Position=i
Log($"Table: ${i} ${Cursor1.GetString("name")}"$) 'displays all tables in database
Next
Dim rs As ResultSet = SQL1.ExecQuery("SELECT name FROM sqlite_master WHERE type='table'")
Do While rs.NextRow
Log($"Table: ${Cursor1.GetString("name")}"$) 'displays all tables in database
Loop
rs.Close
The advantage of using ResultSet is that it is compatible with B4A, B4i and B4J.
Dim rs AsResultSet = SQL1.ExecQuery("SELECT name FROM sqlite_master WHERE type='table'") DoWhile rs.NextRow Log($"Table: ${Cursor1.GetString("name")}"$) 'displays all tables in database Next rs.Close
@Erel is so excited about publishing the latest B4A 7.80 that he uncharacteristically stumbled through his answer which should be;
B4X:
Dim i As Int
Dim rs As ResultSet = SQL1.ExecQuery("SELECT name FROM sqlite_master WHERE type='table'")
Do While rs.NextRow
Log($"Table:${i} ${rs.GetString("name")}"$) 'displays all tables in database
i=i+1
Loop
rs.Close
It is even more advantageous to use the parameterized query as @Erel often advocates:
B4X:
Dim rs As ResultSet = SQL1.ExecQuery2("SELECT name FROM sqlite_master WHERE type=?", _
Array As String("table"))