I use the following code to retrieve all a data from any type of table in a database and show it in a datagrid:
Code: Select all
on populatedatagrid
# curtab contains table name
#let's clean datagrid
set the dgData of group "myDatagrid" to empty
#connection
put the connID of this stack into connID
#now starts the real code
#get column names
put revDatabaseColumnNames(connID, curtab ) into titles
replace "," with return in titles
#let's add the rowid in order to get unique row for further actions
put "rowid" & return before titles
set the dgProp["columns"] of group "myDatagrid" to titles
#let's recover all data from the table in database
put "SELECT rowid,* FROM " & curtab into tSQL
put revDataFromQuery(tab,return,connID,tSQL) into tRecords
set the dgtext of group "myDatagrid" to tRecords
end populatedatagrid
I suppose that I could avoid it using the dgData property, but how can I get an array from a query and use it in a datagrid?