function FillGrid(gObject, db, sqlquery) if db then if ( dbisopen() ) then local stmt = dbprepare(sqlquery) if stmt then --## If we do not know the number of columns that will be retrieved by the query we can do the following ##-- Grid.DeleteAllItems(gObject); Grid.SetColumnCount(gObject, stmtcolumns()); Grid.InsertRow(gObject, -1, false); Grid.SetFixedRowCount(gObject, 1); --## END ##-- Grid.SetRedraw(gObject, false, false); local nLoc = stmtcolumns() nRows = 0; for row in stmtrows() do ----It returns an indexed table like dbrows nRows = nRows + 1 nRowID = Grid.InsertRow(gObject, -1, false); for x=1, stmtcolumns() do if row[x] then Grid.SetCellText(gObject, nRowID, x-1, row[x], false); else Grid.SetCellText(gObject, nRowID, x-1, , false); end end end for n,y in stmtget_names() do Grid.SetCellText(gObject, 0, n-1, y, false); end stmtfinalize(); Grid.SetRedraw(gObject, true, true); Grid.AutoSizeColumns(gObject, GVS_DEFAULT, true) Grid.SetHeaderSort(gObject, true); return nRows end else Dialog.Message("Notice", "You have not selected any database.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1); end else Dialog.Message("Notice", "You have not selected any database.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1); end nRows = nil; end