[Gambas-user] Connecting DataControl to DataSource
Lewis Balentine
lewis at ...3412...
Mon Jan 5 22:35:43 CET 2015
I must be missing something very basic in the use of form database controls.
I can not seem to get a data control populated ...
It appears to me that the data control is not linked to the DataSource.
What am I missing ???
Two additional questions:
Is there a way to access the "Result" object of a DataSource ?
Is there a way to change the "DataSource" for a DataControl ?
Regards,
Lewis Balentine
'----------------------------------------------------------------
Public Sub Form_Open()
Dim I As Integer
' This is A SIMPLE form:
' It has Two controls:
' gb.db.form: DataSource named DataSource1
' gb.db.form: DataView named DataView1
' pvr.FindDB() finds the SQLite3 DB file and opens a connection to it
named "pvr.PvrDb"
pvr.FindDB()
' DataSource is a container that provides data from a database to all
its children and grand-children recursively:
' It uses its Table And Filter properties And an Open Connection To
make a Result object.
' From this Result, it fills its children controls.
' The database Is Defined by the Connection property.
DataSource1.Connection = pvr.PvrDb
DataSource1.Table = "Select StartDateTime, ChannelDigital, Status,
ShowDuration, ShowTitle from TitanTVSchedule Order by StartDateTime,
ChannelDigital"
DataSource1.Filter = ""
Debug DataSource1.Connection.Type '
Debug DataSource1.Connection.Host
Debug DataSource1.Connection.Name
Debug DataSource1.Connection.Type
Debug DataSource1.Connection.Opened
Debug "DataSource1 Record Count: "; DataSource1.Count
Debug "----------------------------------------------"
' This control Implements a TableView that shows the contents Of a
database table And allows To edit it.
' The data Is Provided by the the first DataSource parent control.
' The Columns Property controls the list Of fields To display Or edit.
DataView1.Enabled = True
DataView1.Columns = ["StartDateTime", "ChannelDigital", "Status",
"ShowDuration", "ShowTitle"]
DataView1.Update
Debug "DataView1 Parent: "; DataView1.Parent.Name
Debug "DataView1 Column Count: "; DataView1.View.Columns.Count
Debug "DataView1 Row Count: "; DataView1.View.Rows.Count
End
' Console Window Output:
' pvr.FindDB.409: Open: True /home/lewis/Documents/KWPVR.DB3
' FMain.Form_Open.22: sqlite
' FMain.Form_Open.23: /home/lewis/Documents
' FMain.Form_Open.24: KWPVR.DB3
' FMain.Form_Open.25: sqlite
' FMain.Form_Open.26: True
' FMain.Form_Open.27: DataSource1 Record Count: 31
' FMain.Form_Open.28: - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
' FMain.Form_Open.37: DataView1 Parent: FMain
' FMain.Form_Open.38: DataView1 Column Count: 0
' FMain.Form_Open.39: DataView1 Row Count: 0
' [System]
' Gambas = 3.6.2
' OperatingSystem = Linux
' Kernel = 3.13.0 - 24 - generic
' Architecture = x86_64
' Distribution = Linux Mint 17 Qiana
' Desktop = MATE
' Theme = QGtk
' Language = en_US.UTF - 8
' Memory = 15994 M
' [Libraries]
' Cairo = libcairo.so.2.11301.0
' Curl = libcurl.so.4.3.0
' DBus = libdbus - 1. so.3.7.6
' GStreamer = libgstreamer - 0.10.so.0.30.0
' GStreamer = libgstreamer - 1.0.so.0.204.0
' GTK + 3 = libgtk - 3. so.0.1000.8
' GTK += libgtk - x11 - 2.0.so.0.2400.23
' OpenGL = libGL.so.1.2.0
' Poppler = libpoppler.so.44.0.0
' Qt4 = libQtCore.so.4.8.6
' SDL = libSDL - 1.2.so.0.11.4
More information about the User
mailing list