Hi Klaus,
Yes, i know that the name of the variable was long...
I used this script in two different substacks...So even if the name was long, i had only to change the first line of the script, where was the name of the DataGrid...
But yes, i agree with you that the name of the variable was long...
ok, i already deleted the line of number of records...
This is all the code i am using in this substack...
local sDatabaseID
On opencard
global myPath
put the effective filename of this stack into myPath
set itemdel to "/"
## remove filename of runtime/stack:
delete item -1 of myPath
put "/BBDD/myDatabase.sqlite" AFTER myPath
set the dgData of group "DGPenC" to empty
set the dgData of group "DGImp" to empty
set the visible of group "DGImp" to false
PutNameColumns
end opencard
on PutNameColumns
global theDataGridArray
databaseConnect
put getDatabaseID() into tDatabaseID
put revQueryDatabase( tDatabaseID, " PRAGMA table_info( Rep )") into theCursor
put "DGPragmaRep" into nameTablePragma
if theCursor is an integer then
ConvertSQLCursorToArray theCursor, theDataGridArray
put the result into theError
if theError is empty then
set the dgData of group nameTablePragma to theDataGridArray
answer "value1 " & theDataGridArray[1]["name"]
end if
## Close the database cursor
revCloseCursor theCursor
end if
put the dgData of group nameTablePragma into theDataPragma
answer "value2 " & theDataPragma[2]["name"]
put the dgNumberOfLines of group nameTablePragma into tCounter
answer "Counter" & the dgNumberOfLines of group nameTablePragma
put theDataPragma[1]["name"] into tColumns
put 2 into i
repeat while i <=tCounter
put cr & theDataPragma
["name"] after tColumns
add 1 to i
end repeat
set the dgProp["columns"] of grp "DGPenC" to tColumns
set the dgProp["column labels"] of grp "DGPenC" to tColumns
set the dgProp["columns"] of grp "DGImp" to tColumns
set the dgProp["column labels"] of grp "DGImp" to tColumns
put 1 into i
repeat while i <=tCounter
set the dgColumnAlignment[theDataPragma["name"]] of group "DGPenC" to "left"
add 1 to i
end repeat
answer "end of script"
end PutNameColumns
command ConvertSQLCursorToArray pCursor, @pOutArrayA
local i
local theFields
local theError
## Get the names of all the columns in the database cursor
put revDatabaseColumnNames(pCursor) into theFields
if theFields begins with "revdberr," then
put item 2 to -1 of theFields into theError
end if
if theError is empty then
put 0 into i
## Loop through all rows in cursor
repeat until revQueryIsAtEnd(pCursor)
add 1 to i
## Move all fields in row into next dimension of the array
repeat for each item theField in theFields
put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA[ theField ]
end repeat
revMoveToNextRecord pCursor
end repeat
end if
return theError
end ConvertSQLCursorToArray
command databaseConnect
local tDatabasePath, tDatabaseID
global myPath
put myPath into tDatabasePath
put revOpenDatabase ("sqlite",tDatabasePath,,,,) into tDatabaseID
setDatabaseID tDatabaseID
end databaseConnect
command setDatabaseID pDatabaseID
put pDatabaseID into sDatabaseID
end setDatabaseID
function getDatabaseID
return sDatabaseID
end getDatabaseID
I don't know how to attach you all what i have in this substack ( so the DataGrids) without to create one new application and do it from zero with only this substack...
Anyway it should work if you create one DataGrid with the names of DataGrids i have and then...
regards,
fko