Problem with DataGrid and sqlLite

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
jgayoso
Posts: 13
Joined: Fri Jan 26, 2018 3:25 pm

Problem with DataGrid and sqlLite

Post by jgayoso » 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

MaxV
Posts: 1540
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Problem with DataGrid and sqlLite

Post by MaxV » Mon Jan 29, 2018 1:02 pm

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")
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

jgayoso
Posts: 13
Joined: Fri Jan 26, 2018 3:25 pm

Re: Problem with DataGrid and sqlLite

Post by jgayoso » Thu Feb 01, 2018 6:24 pm

MaxV, thanks.

It was that little detail ...

Greetings from the south of the world

MaxV
Posts: 1540
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Problem with DataGrid and sqlLite

Post by MaxV » Fri Feb 02, 2018 1:37 pm

just1lineCode.png
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

bogs
Posts: 2373
Joined: Sat Feb 25, 2017 10:45 pm

Re: Problem with DataGrid and sqlLite

Post by bogs » Fri Feb 02, 2018 4:04 pm

Oh that is a good one Max :mrgreen:
Image

Post Reply

Return to “Databases”