Android Question MYSQL I NEED GET DATA

macerau

Member
Licensed User
Longtime User
All I need is for the 3 lines below the yellow to work!
I have already tried with list, map, JSONParser and I can not get the result below in this example:

first time
LOG->RA
LOG->REGISTRO
second time
LOG->B0000264
LOG->0000000
third time
LOG->B0000182
LOG->0000013
....

BUT...
 
Last edited:

macerau

Member
Licensed User
Longtime User
Good afternoon Erel, for months I have this problem,
in the past I tried to ask for your help,
but for language problem I ended up giving up,
From what I imagine you could end my doubt with 3 or 4 lines, Because the data I want is there and visible, I just do not know the command to extract the data!
I've even done a routine to decode the mounted string but it makes the process slow!
Give me what it takes so you can help me?
I used a photo so I can see how simple it is!
When I get the result of a SELECT through http everything works but if I use MYSQL it does not!
Please help me with this if you understood the Google translation.



I need to get the contents of the field by the name of the field, and not go looking in a string for its position

I used this routine to work around the problem but this I know is not the correct solution
c1= G.CHOOSE(1,S,",") 'CRM

Public Sub CHOOSE(I As Int, S As String,SP As String) As String
Dim J As Int
Dim PA As Int
Dim K As Int
Dim F As Int
Dim P As Int
Dim M As Int
Dim V As String
If I=1 Then
J=InStr(S,SP)

If J=0 Then J=Len(S)
V=sf.Trim(sf.Mid(S,2,J-2))
Return V
Else
F=InStr(S,"]")
J=InStr(S,SP)
K=1
For K=2 To I
PA=J
J=InStrI(J+1,S,SP)
If J=0 Then J=F-1
If J=PA Then J=F-1
Next

P=PA + 2
M= J - P +1
V=sf.Trim(sf.Mid(S,P,M))
Return V

End If

End Sub
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Hi macerau

So you've got some data in a MySQL database and want to read that data from the database?

You're not trying to access a SQLite DB are you?

Is the database located on your Android device or remotely?

For SQLite I use something like this

B4X:
Dim SQL1 As SQL

    Cursor = SQL1.ExecQuery("SELECT _id, name,column1,column2 FROM table order by name")   

    For i=0 To Cursor.RowCount-1

        Cursor.Position=i
   
         nameVar = Cursor.GetString("name")

    Next

    Cursor.Close

Is the problem that you've gone past the number of rows in that table? You count to 11 but of course you'd go from 0-11 so actually 12 records. Are there at least 12 records in that table? This is why my code above uses .RowCount-1... This might solve your problems - have you stepped through that code to see how many times it iterates through?

Hope this helps
 
Upvote 0

macerau

Member
Licensed User
Longtime User

Eps, I was happy for your efforts to help me, but the expression
Cursor = db.Query (("select REGISTRY, RA from consu.orcB")
is not accepted because db.query is Java.util.Arraylist!
As you can see from the Screenshot the values are in the Java.util.Arraylist type variable and I think the people who developed B4A would have my answer ready!
The database is MySql itself and this remote!
But I do not know what else to do to get their attention to help me!
And I have been their clients since the beginning of development!


People like you are who encourage us to continue Thank you
Raul
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
The list returned from db.query is a list of arrays(each element of the list is a selected ROW)
you must define m as list and look at each element as an array.
I use JRDC to handle remote DB and I never used that library and I don't think it's no more supported.

Mauro
 
Upvote 0

Magma

Expert
Licensed User
Longtime User

How will put in list the fields from rows list ?
(need to be for every line and how ? - need small example)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…