Is there a method in Xojo to not duplicate the same rows?

92 views Asked by At

I did this grid in Xojo. The problem is that it duplicates the same rows as before even if I go out and back.

That's the original table with only 3 records:

enter image description here

Then I made a method to add rows:

Dim i As Integer
Dim v As String
Dim count As Integer
Dim theSQL As String
Dim f As FolderItem
Dim found As Boolean
Dim fin As Integer
Dim vdescrizione1 As String
dim vdatafin as String
dim VnumRec as Integer

//DB MYSQL
Dim db As MySQLCommunityServer
Dim dbfile As folderItem
Dim rec As databaserecord
Dim rs As recordSet

//initialization DB MYSQL
rec=New databaserecord
db=New MySQLCommunityServer

//CONNECTION WEB
db.host ="----"
db.userName = "----"
db.password ="-----"
db.port=----
db.databaseName ="----"

If db.connect Then
Else
MsgBox "MYSQL Portal Data File not available" 
End If

theSQL="Select id,nome,cognome,sesso,residenza,annoNascita FROM CnaPr.Utente"

rs=db.sQLSelect(theSQL)

dim intCycle as Integer=1
dim intMax as Integer = 1000
dim intRow as Integer
dim vfp as Integer
dim r as new Random
dim cValue as Color = rgb( r.InRange( 0, 255 ), r.InRange( 0, 255 ), r.InRange( 0, 255 ) )
dim blnED as Boolean

while not rs.eOF
dim dict as new Dictionary( "K_ID" : rs.field("id").value, _
"K_Nominativo" :  rs.field("nome").value, _
"K_Cognome" :  rs.field("cognome").value, _
"KSesso" :  rs.field("sesso").value,_
"KFinePratica" :  blnED, _
"K_Residenza" :  rs.field("residenza").value,_
"K_Data" :  rs.field("annoNascita").value)

 dim newRow as new GraffitiWebGridRow( dict )
 newRow.Tag = intRow
 AllRows.Append( newRow )
 rs.MoveNext
 Wend

 gwpMain.TotalPages = Ceil(intMax / 20)
 LoadPage( 0 )

The second method:

dim pageMin as Integer = pageIndex * rowsPerPage
//rowsPerPage
dim pageMax as Integer = pageMin + rowsPerPage
dim maxPages as Integer = (AllRows.Ubound +1 ) / rowsPerPage

if pageIndex < 0 or pageIndex > maxPages then Return

GridList.LockUpdate = True
GridList.DeleteAllRows()

for intCycle as Integer = pageMin to Min( pageMax - 1, AllRows.Ubound )
GridList.AddRow( AllRows(intCycle) )
next
GridList.LockUpdate = False
currentPage = pageIndex

When I go back to the previous page and then go back to the table, it doesn't leave me the records I had, but on the contrary it duplicates them.

enter image description here

0

There are 0 answers