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

M.LAZ

Active Member
Licensed User
Longtime User
Hi guys,, who could help me

my db has two tables : users,students
users table has 3 fields : id(int(11)/auto increment/pk),user_name(varchar(80)/string),pass(text/SHA1)
students table has 4 fields : id(int(11)/auto increment/pk),name(varchar(20)/string),age(int(3)),grade(float)

Insert/Update/Delete ==> In User or Student table just one is enough
Display and Retrieve fields and display them in a table view or grid

flexible table

with this example will help alot of newbie like me,,
any help will appreciated !
 

Attachments

  • MySQLTest.zip
    7.9 KB · Views: 234

Peter Simpson

Expert
Licensed User
Longtime User
Hello @lazreg,
The following code will retrieve your 5 users from the users table, it's not difficult to add the results into the Flexible Table.just download the example and adapt your code to suit. Read the code in Flexible table to learn how it works.

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    Dim db As MySQL

            'my db has two tables : users,students
            'users table has 3 fields : id(Int(11)/auto increment/pk),user_name(varchar(80)/String),pass(text/SHA1)
            'students table has 4 fields : id(Int(11)/auto increment/pk),name(varchar(20)/String),age(Int(3)),grade(Float)
            '    
            'Insert/Update/Delete ==> In User OR Student table just one Is enough
            'Display AND Retrieve fields AND display them In a table View OR grid
            '
            'flexible table 
            '
            'with this example will help alot of newbie like Me,,
            'any help will appreciated !
            '
            'HostName : sql5.freesqldatabase.com
            'dbUserName: sql575554
            'dbPassword: qV1*wB5*
            'db Name : sql575554
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
   
    'DisableStrictMode
    '                            free host               
    db.Initialize("MySQL", "sql5.freesqldatabase.com", "sql575554","qV1*wB5*", "sql575554")
    db.QueryASync2("SELECT * FROM `users`", 1)
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

'MYSQL RESULTS
Sub MySQL_BatchResult(batch As Map) 'Not tested
    Log(batch.Size)
End Sub

Sub MySQL_ExecResult(meta As Map)
    Log(meta.Size)
End Sub

Sub MySQL_ListTables(tables As List, ms As Long)
    For i = 0 To tables.Size - 1
        Log(tables.Get(i))
    Next
    Log(tables.Size)
End Sub

Sub MySQL_Status(Connected As Boolean, ReConnecting As Boolean, RetriesLeft As Int)
    Log(Connected)
End Sub

Sub MySQL_QueryResult(data As List, meta As Map)
    For i = 0 To data.Size - 1
        Log(data.Get(i))
    Next
    Log(data.Size)   
    Log(meta.Size)   
End Sub

Sub MySQL_QueryResult2(data As List, meta As Map)
    ToastMessageShow(meta.Get("RecordCount") & " rows retrieved in " & meta.Get("ms") & " milliseconds", True)

    For i = 0 To data.Size - 1
        Log(data.Get(i))
    Next
    Log(data.Size)
    Log(meta.Size)
End Sub
 

guido valentino

Member
Licensed User
Longtime User
hello, how do I make a comparison between the values in the database and a value that I insert? I used T his code but does not work
B4X:
Sub Bt1_Click
    name=Et1.Text
    db.QueryASync("SELECT Nome from Utenti;","")
End Sub

Sub MySQL_QueryResult(data As List, meta As Map)
        Dim utente_presente=0 As Int
            For i = 0 To data.Size-1
                If name = data.Get(i) Then
                    utente_presente=1
                Else
                    utente_presente=0
                End If
            Next
        If utente_presente=1 Then
            Msgbox("Presente","")
        Else
            Msgbox("Assente","")
        End If
End Sub
 

sigster

Active Member
Licensed User
Longtime User
Hi

Thanks for the Library

If I call my Mysql database I get this error
SqlException: java.sql.SQLException: Unsupported character encoding 'X-UNICODEBIG'.

I have table name and mobile number with DecodeBase64
 

shashkiranr

Active Member
Licensed User
Longtime User
Hi All,

I am trying to connect to local host. I have installed XAMPP and set up my sql db using phpmyadmin. I am getting the error "not Connected to Database" . I am using the below line to initialize

db.Initialize("MySQL","http://localhost","admin","admin","ebook")

I tried 127.0.0.1, 10.0.0.2 in place of localhost but still not working. I do not know where i am going wrong.

Regads,
SK
 

DonManfred

Expert
Licensed User
Longtime User
so the app is running on your pc running xampp? Must be. Your database is only from your pc available on localhost.

Localhost on your device is THE DEVICE ITSELF

Use the local IP of your PC in your network to connect to it when you are in WIFI range and connected to the same network
 

shashkiranr

Active Member
Licensed User
Longtime User
Hi Don,

Yes XAMPP is running on my pc. I used my pc ip adress but getting the same error.

Regards,
SK
 

Peter Simpson

Expert
Licensed User
Longtime User
127.0.0.1/localhost points to internal loopback, so no router is involved when routing to port. Add port 3306 to Windows firewall settings.

What version of Windows are you using?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…