Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sqlite.ToQmGrid ...Adding multiple tables to same grid
#1
Hi Gintaras,
This may be a tough one...
I am trying to add the data in numerous tables in the same sqlite database (all formatted the same).
I tried to use Sqlite.ToQmGrid in a loop for each table but it erases the current contents each time.
I tried to make a custom member function based on Sqlite.ToQMGrid but with the erase line taken out but the number of rows I think caused an error to be thrown

Member function Sqlite.ToQmGridWithoutGridClear
Code:
Copy      Help
function hgrid $sql [flags] ;;flags: 1 except first column

;Populates QM_Grid control with data from database.
;Error if something fails, eg if SQL is incorrect.
;Error if column count in query results is greater than grid column count minus flag 1.

;hgrid - QM_Grid control handle or DlgGrid variable.
;sql - SQL statement that selects data to be displayed in the grid. For example, "SELECT * FROM table1" displays whole table1.

;<open "sample_Grid_Sqlite">Example</open>


type ___SQLITEQG DlgGrid'g ncol firstcol nr ~es

___SQLITEQG x.g.Init(hgrid)
x.firstcol=flags&1
x.ncol=x.g.ColumnsCountGet-x.firstcol
;x.g.RowsDeleteAll(x.firstcol)

ExecF(sql &Sqlite_QgCallback &x)
err
,if(x.es.len) end x.es
,end _error


Ideally I would write a single Sqlite SELECT statement that joins all the tables but can't figure out how to do it.

Any ideas?
Thanks, Stuart
#2
not tested

Member function Sqlite.ToQmGrid2
Code:
Copy      Help
function hgrid $sql [flags] ;;flags: 1 except first column, 2 append

;Populates QM_Grid control with data from database.
;Error if something fails, eg if SQL is incorrect.
;Error if column count in query results is greater than grid column count minus flag 1.

;hgrid - QM_Grid control handle or DlgGrid variable.
;sql - SQL statement that selects data to be displayed in the grid. For example, "SELECT * FROM table1" displays whole table1.

;<open "sample_Grid_Sqlite">Example</open>


type ___SQLITEQG DlgGrid'g ncol firstcol nr ~es

___SQLITEQG x.g.Init(hgrid)

x.firstcol=flags&1
x.ncol=x.g.ColumnsCountGet-x.firstcol

if(flags&2) x.nr=x.g.RowsCountGet
else x.g.RowsDeleteAll(x.firstcol)


ExecF(sql &Sqlite_QgCallback &x)
err
,if(x.es.len) end x.es
,end _error
#3
tested
will be in next QM
#4
Thanks so much!!!!
S


Forum Jump:


Users browsing this thread: 1 Guest(s)