Android Question loop with sql problem

tufanv

Expert
Licensed User
Longtime User
Hello ,

I have a code like this :
B4X:
Do While i < spinneradet.SelectedItem '
    cursor3 = sqlfleet.ExecQuery("SELECT ID FROM tblfleet")
      If cursor3.RowCount > 0 Then
        For i = 0 To cursor3.RowCount - 1   
      cursor3.Position = i
   
      Dim NewID As Int
      NewID = cursor3.GetInt("ID")
      Next

      End If
     
      NewID = NewID +1 ' add 1 to the ID number to make a new ID field
      sqlfleet.ExecNonQuery("INSERT INTO tblfleet VALUES('0','"&(lblmonthly3.Text/spinneradet.selecteditem)&"','" & cursor4.GetString("aircraft") & "','" & btnbuy.text & "','" & "0.0" & "','" & "TC-" & txtcountry.text & "','" & NewID & "')")
      dbload3
   
  i = i + 1
Loop

The problem is : When the database have no records ( when the row count is 0 ) there is no problem , loop works perfect and add records to sql with no problem (when spinneradet is 5 for example it adds 5 records ) but after this when the row count is NOT zero , even when i select to add 5 more records with spinner , it just add 1 record , does not loop to other other 4 records. Shortly when the sql is empty there is no problem but when there are reords added previously i cant add 5 records with one button click it just add one. Where am i wrong ?

TY
 
Top