Page 1 of 1

Problem with DataGrid and sqlLite

Posted: Fri Jan 26, 2018 3:56 pm
by jgayoso
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

Re: Problem with DataGrid and sqlLite

Posted: Mon Jan 29, 2018 1:02 pm
by MaxV
Did you try with this?

Code: Select all

set the dgText of group "DataGrid_1" to revDataFromQuery(TAB, return, gSQLiteID, "SELECT * FROM carta order by carta_codigo ASC")

Re: Problem with DataGrid and sqlLite

Posted: Thu Feb 01, 2018 6:24 pm
by jgayoso
MaxV, thanks.

It was that little detail ...

Greetings from the south of the world

Re: Problem with DataGrid and sqlLite

Posted: Fri Feb 02, 2018 1:37 pm
by MaxV
just1lineCode.png

Re: Problem with DataGrid and sqlLite

Posted: Fri Feb 02, 2018 4:04 pm
by bogs
Oh that is a good one Max :mrgreen: