Gambas sqlite

Post Reply
jessa
Posts: 2
Joined: Tuesday 26th September 2017 12:55am

Gambas sqlite

Post by jessa » Wednesday 27th September 2017 8:22am

How to use sqlite in gambas? I'm using gambas in raspberry pi and DB browser for Sqlite.

stevedee
Posts: 76
Joined: Monday 20th March 2017 6:06pm

Re: Gambas sqlite

Post by stevedee » Wednesday 27th September 2017 10:45am

Thats a big question, and I don't know how much you know about Gambas & Sqlite, but you will need to include the gb.db component and if you want to use Data Bound controls gb.db.form.

This is the simplest code I can think of to get you started;

Create a new project and add a textArea to the Form. Enter this text:-

Code: Select all

' Gambas class file

Private dbConnection As New Connection

Public Sub Form_Open()
Dim myTable As Table

  dbConnection.Name = "/home/steve/Gambas/my-tv/me-tv.db" 'the path to a valid database
  dbConnection.Type = "sqlite3"
  TextArea1.Clear()
  Try dbConnection.Open()
  ' display each database table name
  For Each myTable In dbConnection.Tables
    TextArea1.Text &= myTable.Name & gb.CrLf
  Next

End

When you run this code using a valid database, the textArea should list your database tables.

jessa
Posts: 2
Joined: Tuesday 26th September 2017 12:55am

Re: Gambas sqlite

Post by jessa » Thursday 28th September 2017 4:47am

Thank you very much! I'l try the code.

Post Reply