Problem with DataGrid and sqlLite
Posted: Fri Jan 26, 2018 3:56 pm
My table in sqlLite has 6 records, but the datagrid repeats the last record twice.
If I delete 1 record, I repeat it 3 times and if I delete another 4 times.
Function fDespliega_Carta
put "" into tPaso
put revQueryDatabase( gSQLiteID, "SELECT * FROM carta order by carta_codigo ASC" ) into theCursor
put revDatabaseColumnNames(theCursor) into theFields
ConvertSQLCursorToArray theCursor, theDataGridArray
put the result into theError
if theError is empty then
set the dgData of group "DataGrid_1" to theDataGridArray
end if
end fDespliega_Carta
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
if theField = "carta_precio" then
put numFormat(revDatabaseColumnNamed(pCursor, theField),"$#.###.###.##Z") into pOutArrayA[ theField ]
else
put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA[ theField ]
end if
end repeat
revMoveToNextRecord pCursor
end repeat
end if
return theError
end ConvertSQLCursorToArray
If I delete 1 record, I repeat it 3 times and if I delete another 4 times.
Function fDespliega_Carta
put "" into tPaso
put revQueryDatabase( gSQLiteID, "SELECT * FROM carta order by carta_codigo ASC" ) into theCursor
put revDatabaseColumnNames(theCursor) into theFields
ConvertSQLCursorToArray theCursor, theDataGridArray
put the result into theError
if theError is empty then
set the dgData of group "DataGrid_1" to theDataGridArray
end if
end fDespliega_Carta
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
if theField = "carta_precio" then
put numFormat(revDatabaseColumnNamed(pCursor, theField),"$#.###.###.##Z") into pOutArrayA[ theField ]
else
put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA[ theField ]
end if
end repeat
revMoveToNextRecord pCursor
end repeat
end if
return theError
end ConvertSQLCursorToArray