[chargeable] MSMySQL - Yet another MySQL-Library (but a FAST one :-))

taufik adi sanjaya

Member
Licensed User
Longtime User
Northwind database mysql with 1108 record




Sub lv1_ItemClick (Position As Int, Value As Object)
Dim t As String = Value
db.QueryASync("select * from "&t&";",t)
End Sub

How to limit command ???
db.QueryASync("select * from "&t&"limit 100;",t) <--- Error
 

MarcoRome

Expert
Licensed User
Longtime User

select * from "&t&"limit 100;",t
Maybe forget SPACE between "&t&" and limit
 

taufik adi sanjaya

Member
Licensed User
Longtime User
It's working, but how to retrieve next 100 record. I mean 101 - 200
or it's posiblle to make pagination ???
 
Last edited:

taufik adi sanjaya

Member
Licensed User
Longtime User
I was changed Listview_click with button1_click and define dim....

No error but data can't show in listview, what's wrong with my code ??

Sub Button1_Click
'Dim m As Map
Dim data As List
Dim t As String ="koneksi"

data.Initialize

db.QueryASync("select * from "&t&";",t)

For i=0 To data.Size-1
Dim cur As Map = data.Get(i)
lv2.AddTwoLines(cur.Get("PC")&CRLF&cur.Get("NAMAROOM"),cur.Get("STATUSK")&CRLF&cur.Get("NAMA"))
Next

End Sub


 

DonManfred

Expert
Licensed User
Longtime User
No error but data can't show in listview
Because you are doing it the wrong way!?
B4X:
db.QueryASync("select * from "&t&";",t)
After calling this you need to wait for the result event get raised. In THIS event-sub you then need to use the values you get from the database.
 

taufik adi sanjaya

Member
Licensed User
Longtime User
It's mean, we must using

B4X:
Sub MySQL_QueryResult(data As List, meta As Map)
       For i=0 To data.Size-1
        Dim cur As Map = data.Get(i)                   
        lv2.AddTwoLines(cur.Get("PC")&CRLF&cur.Get("NAMAROOM"),cur.Get("STATUSK")&CRLF&cur.Get("NAMA"))       
Next
End Sub

Can't direct on Button1_click ???
 

DonManfred

Expert
Licensed User
Longtime User
Query and QueryAsync are two different types. The later is the correct use. I removed Query from the old library. Query blocks the mainthread.
If you device has slow connection and fetching a lot of data. Android may decide to kill your app.
In production Android may decide to block your app in Appstore. Be careful.

Use Async methods.
 

taufik adi sanjaya

Member
Licensed User
Longtime User
Thank's Don,

How to get result from QueryResult2 ??? I have error to get it...


B4X:
Sub MySQL_QueryResult(data As List, meta As Map)
    Dim m As Map = meta
   
    lvlagu.Clear
   
    For i=0 To data.Size-1
        If m.Get("TaskID") = "datautm" Then
            Dim cur As Map = data.Get(i)                   
            lvlagu.AddTwoLines(cur.Get("JDL_LAGU")&" - "&cur.Get("PENYANYI"),cur.Get("SPATH"))
        End If
End Sub

Sub MySQL_QueryResult2(data As List, meta As Map)
    Dim m As Map = meta

    lvlist.Clear
   
    For i=0 To data.Size-1
        Log(data.Get(i))
        If m.Get("TaskID") = "pc4" Then
            Dim cur As Map = data.Get(i)                   
            lvlist.AddTwoLines(cur.Get("JDL_LAGU"),cur.Get("PENYANYI"))
        End If
    Next
End Sub


Best regards,
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…