What's New :
- New : Updated to AutoPlay Media Studio 8
- New : Help file now integrated to plugin (except actions)
- Note : Plugin now requires minimum Windows 2000
Download : Click Here
function AppendGrid(gObject, sqlquery, title)
if db then
if ( db:isopen() ) then
local stmt = db:prepare(sqlquery)
if stmt then
--## If we don't know the number of columns that will be retrieved by the query we can do the following ##--
if (Grid.GetColumnCount(gObject)) < (stmt:columns()) then
for b=1, ((stmt:columns())-(Grid.GetColumnCount(gObject))) do
Grid.InsertColumn(gObject, -1, false);
end
end
Grid.InsertRow(gObject, -1, false);
local j = Grid.InsertRow(gObject, -1, false);
if title then --it's like a subtitle that describes what we're going to append
Grid.SetCellText(gObject, j, 0, title, false);
else
Grid.SetCellText(gObject, j, 0, "", false);
end
local k = Grid.InsertRow(gObject, -1, false);
--## END ##--
Grid.SetRedraw(gObject, false, false);
for n,y in stmt:get_names() do
Grid.SetCellText(gObject, k, n-1, y, false);
end
for row in stmt:rows() do ----It returns an indexed table like db:rows
nRowID = Grid.InsertRow(gObject, -1, false);
for x=1, stmt:columns() 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
Grid.AutoSizeColumns(gObject, GVS_DEFAULT, false);
Grid.ExpandLastColumn(gObject, false);
Grid.SetRedraw(gObject, true, true);
stmt:finalize();
end
else
Dialog.Message("Notice", "You haven't selected any database.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
end
else
Dialog.Message("Notice", "You haven't selected any database.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
end
end
. 3 more ways to read a database and fill the grid. I hope this could help.
db:exec("CREATE TABLE ProfServ (id INTEGER PRIMARY KEY, cdat, cust, desc, proj, lang)")
db:exec("INSERT IGNORE INTO ProfServ (id, cdat, cust, desc, proj, lang) VALUES (NULL, '".. s_cdat .."', '".. s_cust .."', '".. s_desc .."', '".. s_proj .."', '".. s_lang .."')");
world = "world"; hello = [[Hello ]]..world..[[!]];
Leave a comment: