Android Question SQL table desc query

harinder

Active Member
Licensed User
Longtime User
Hello..
In the SQLDButils example given in the Source code folder, how can I display table in descending order after I add a row?

In the btnaddnew_click sub, I am trying

Dim query1 as Query
Dim curs as Cursor
query1=select * from persons ORDER BY Col1 DESC
curs= execnonquery ("select * from persons ORDER BY Col1 DESC")

But nothing is happening.
This might be a very basic question.But, I have just started learning.Thank you for your patient reply.

Regards..
 

Mahares

Expert
Licensed User
Longtime User
Your code should be like this:
B4X:
Sub Process_Globals
    Dim sql1 As SQL  'need to check mark the SQL library in lib pane
End Sub

Dim query1 As String
    Dim curs As Cursor
    query1="Select * from persons ORDER BY Col1 DESC"
    curs= sql1.ExecQuery(query1)
 
Upvote 0

harinder

Active Member
Licensed User
Longtime User
In the Edit module in the FillWebView routine you can change this line
Query = "SELECT * FROM " & Main.DBTableName
by this one:
Query = "SELECT * FROM " & Main.DBTableName & " ORDER BY ID DESC"
Thank you klaus..once again your solution has worked perfectly:)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top