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

avrtech

Member
Licensed User
I have another question to the library ...
How do I switched on the internet the program gives an error at line 429 requests understands that at this time trying to connect to the database but from lack of access to the Internet is not able to connect.
How at program startup can check if an Internet connection?
1. If you download data connection
2. If there is no connection to the Internet show a window that turn on WiFi or data transfer application to run properly and only when you click OK to close the program but will not show any error.
Regards
 

avrtech

Member
Licensed User
welcome back

For a long time I am trying to enter the label connection data read from the mysql database

I'm trying to save the data in this way:

B4X:
Label_connect.Text = "Ostatni odczyt: " & db.QueryASync("SELECT data_czas FROM meteo_pogoda LIMIT 0,1;","")

The data that should drive up looks like this: 2016-01-10 16:10:00

Exactly this data I am trying to enter in label_connect.Text

Does anyone with colleagues can give me a hint as I'm typing this data read from mysql? I read the whole subject but with the understanding that some codes have a big problem because I try to write in B4A program literally for a few days ... and these few days I have contact with B4A because I'd asked for leniency and a piece of code as I enter data into the field label?
 

DonManfred

Expert
Licensed User
Longtime User
Label_connect.Text = "Ostatni odczyt: " & db.QueryASync("SELECT data_czas FROM meteo_pogoda LIMIT 0,1;","")
This will not work! You need o wait for the result event raised....
In this event you cn get the data out from the result and show it in a label or whatever.
See the link i posted above whit the Example code... And try to understand what is happening and when.
 

avrtech

Member
Licensed User
Frankly I read this sample code dozens of times, but for the novice it's very not understand maybe if they were descriptions of what is responsible for what and why this happens then I would understand at the moment, too few know the encoding basic and hence it is that my great do not know .
I read this post many times I tried to arrange something with it but unfortunately I am unable to help himself



Could you write a short example for my application? It will be easier for me to learn the code and knowledge.
 
Last edited:

avrtech

Member
Licensed User
As well I understand that this piece of code is right for me:

B4X:
Sub MySQL_QueryResult(data As List, meta As Map)
  'Dim m As Map = meta
  Log("MySQL_QueryResult("&meta&")")
  For i=0 To data.Size-1
  'Log("r:"&data.Get(i))
  Next 
End Sub


Just did not quite understand what he was doing Log and what is the for loop commented out in the Log.

It seems to me that I could write something like this:

B4X:
Sub MySQL_QueryResult(data As List, meta As Map)

   Label_connect.Text = "Ostatni odczyt: " & MySQL_QueryResult("&meta&")

End Sub


Or something like that will work properly ??
 

avrtech

Member
Licensed User
B4X:
Sub MySQL_QueryResult(data As List, meta As Map)
  
     Label_connect.Text = meta
      
End Sub

returns me the result {ColumnCount=1, RecordCount=1, TaskID=, ms=71} everything is good only as display data retrieved from the database?
 

avrtech

Member
Licensed User
Ok this query:
B4X:
Sub Activity_Resume
   
        db.QueryASync("SELECT data_czas FROM meteo_pogoda ORDER BY data_czas DESC LIMIT 0,1;","")

End Sub

and this event:

B4X:
Sub MySQL_QueryResult(data As List, meta As Map)
   
     Label_connect.Text = data
       
End Sub

returns me the result:

[{data_czas=2016-01-10 19:40:00.0}]

I have no idea where it came from these .0 at the end
but I also question how to parse this data now?

To have only:

2016-01-10 19:40:00

??
 

avrtech

Member
Licensed User
For i = 0 To data.Size
Label.Text = data.get(i)
Next

This code calls me a similar result but without the square brackets

{data_czas=2016-01-10 23:50:00.0}

In contrast, a string must look like in a database that is:

2016-01-10 23:50:00

I do not know where it comes at the end .0
 

avrtech

Member
Licensed User
Ok everything works, we managed to retrieve more data from the database and distribute the received data to the right place.

Thanks for your help ... now go on to write an application
 

Pablo Torres

Active Member
Licensed User
Longtime User
Sorry for the trouble, I need help
I keep having the same error: java.lang.nullpointerexception
I cant fix it
I'm gonna upload the whole code
can someone take a look for me?
please!!!
 

Attachments

  • Resto.zip
    11.5 KB · Views: 188

DonManfred

Expert
Licensed User
Longtime User
Seems your Database is NOT accessible from outside
Tried to connect with HeidiSQL... With success.

Have you added internet-permission to the app? No.
I added the permission

Add
B4X:
AddPermission(android.permission.INTERNET)                                  ' Allows applications to open network sockets.
AddPermission(android.permission.ACCESS_NETWORK_STATE)                      ' Allows applications to access information about networks.
to your manifest
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…