Ayabonga
Member
Hello guys,
I am new from MYSQL and I have created a localhost database in PHPMyAdmin. I want to check if a city and country exist in my database. I have built up from JRDC2 tutorial.
Can you please advise:
SQL Command in the Config File:
sql.check_user =SELECT IF EXIST *FROM cities WHERE country = ? AND city = ?
B4A Code:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			I am new from MYSQL and I have created a localhost database in PHPMyAdmin. I want to check if a city and country exist in my database. I have built up from JRDC2 tutorial.
Can you please advise:
SQL Command in the Config File:
sql.check_user =SELECT IF EXIST *FROM cities WHERE country = ? AND city = ?
B4A Code:
			
				B4X:
			
		
		
		Sub btn_checkUser_Click
    
    If editCountry.Text = "" Or editCity.Text = "" Then
        Msgbox("country or city data is missing", "Missing data")
        Return
    End If
    
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("check_user", Array As String(editCountry.Text, editCity.Text))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j,"req")
        Wait For (req) req_Result(res As DBResult)
        Dim row() As Object = res.Rows.Get(0)
        Dim longitude As Double = row(2)
        Dim latitude As Double = row(res.Columns.Get("latitude"))
        lblResult.Text = $"$1.3{latitude} / $1.3{longitude}"$
        Log("Country and City Exist!")
    
Else
        Log("County or City Not exist!")
        Log("Error: " & j.ErrorMessage)
    End If
    j.Release
End Sub