Android Question cannot assign void value

ronell

Well-Known Member
Licensed User
Longtime User
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
  
Sub Process_Globals

    Dim MYSQIP = "xxx.xxx.xxx.xx" As String
    Dim MYSQPORT = "xxxx" As String
    Dim MYSQUSER = "mocpayne" As String
    Dim MYSQPASS = "xxxxx" As String
    Dim MYDB = "mocpayne_sample" As String
    Dim connection As MariaDBConnector

    Dim cursor1 As Cursor
End Sub

Sub Globals

  
  
    Private Button1 As Button
    Private EditText1 As EditText
    Private EditText2 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
  
        Activity.LoadLayout("main")
        connection.Initialize(MYSQIP,MYSQPORT,MYSQPASS,MYSQUSER,MYDB)
          
      
      
  
  

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
    If EditText1.text = "" And EditText2.Text = "" Then
        Msgbox("fill up the fields","error")
      
    Else
      
        cursor1 = connection.ExecQuery("query","SELECT * FROM Accounts where user_name='" & EditText1.Text & "' and user_password='" & EditText2.Text & "'")
        If cursor1.RowCount<>0 Then
            Msgbox("login successful","")
            End If
          
    End If
  
End Sub

i have this error: Cannot assign void value.

i want to connect my app to mySQL database by entering user and pass in the 2 textboxes, dont know if my codes are correct
 

udg

Expert
Licensed User
Longtime User
There is a preliminary condition you should be aware of: most (if not all) MySQL installations don't provide direct access outside the hosting server, for security reasons.
If that's your case, you should deploy something (B4J program or PHP module) on the server and let this latter module interact with the DB on one hand and your app on the other one.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
cursor1 = connection.ExecQuery("query","SELECT * FROM Accounts where user_name='" & EditText1.Text & "' and user_password='" & EditText2.Text & "'")
ExecQuery does NOT have a returnvalue! It is declared as void.

The Method will NOT return a CURSOR.... It is a async-call. The result will be raised in a Event.
 
Upvote 0

ronell

Well-Known Member
Licensed User
Longtime User
There is a preliminary condition you should be aware of: most (if not all) MySQL installations don't provide direct access outside the hosting server, for security reasons.
If that's your case, you should deploy something (B4J program or PHP module) on the server and let this latter module interact with the DB on one hand and your app on the other one.
can i call the php module using 1button_click ?
 
Upvote 0
Top