Android Question Get Schema Table in sql lite

Oldmanenzo

Member
Licensed User
Longtime User
I have the need of having to cancel some tables linked to the main table, 5 of which I know the name at first, because they are created with the main table, but the others can be created by the user depending on the needs that are appropriate to the main table changing only the suffix.
example
log
Log_Dxcc_Award
Log_Iota_Award
etc.
in visual studio with visual basic use this function in oledb
but here and sql lite do not know how to get the database schema

B4X:
Public Function GetSchemaTable(ByVal connectionString As String) As DataTable
        Using connection As New OleDb.OleDbConnection(connectionString)
            connection.Open()
            Dim schemaTable As DataTable = _
                connection.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Tables, _
                New Object() {Nothing, Nothing, Nothing, "TABLE"})
            Return schemaTable
        End Using
    End Function
 

Mahares

Expert
Licensed User
Longtime User
Suppose I have 4 tables: Log, Log_Dxcc_Award, Log_Iota_Award, Log_Super_Award
The database schema in a SQLite database is stored in a special table named "sqlite_master"
If I want to display only the tables that end with the word: Award, I do this:
B4X:
  Dim objCursor As Cursor
    Dim txt As String
    txt="SELECT * FROM sqlite_master WHERE type = 'table' and name like '%Award' " 
    objCursor = SQL1.ExecQuery(txt)
    For i = 0 To objCursor.RowCount-1
         objCursor.position =i
        Log(objCursor.GetString("name") )  'displays table name that ends with Award
    Next
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Suppose I have 4 tables: Log, Log_Dxcc_Award, Log_Iota_Award, Log_Super_Award
The database schema in a SQLite database is stored in a special table named "sqlite_master"
If I want to display only the tables that end with the word: Award, I do this:
B4X:
Dim objCursor As Cursor
    Dim txt As String
    txt="SELECT * FROM sqlite_master WHERE type = 'table' and name like '%Award' " 
    objCursor = SQL1.ExecQuery(txt)
    For i = 0 To objCursor.RowCount-1
         objCursor.position =i
        Log(objCursor.GetString("name") )  'displays table name that ends with Award
    Next
 
Upvote 0

Oldmanenzo

Member
Licensed User
Longtime User
very very clear. When I read the word master, I immediately made reference to sql server and sql compact using the same system.
thanks a lot
 
Upvote 0
Top