MySQL version blog post

  1. 4 months ago

    Rick A

    May 15 (Brazil. GMT-3:00)
    Edited 4 months ago

    The code in the blog post seems unusual, with a loop for a one row result, so I suggest someone verify if this code works instead:

    Dim db As New MySQLCommunityServer
    Dim mySQLversion As String = "Error"
    
    db.Host = "somehost"
    db.port = 3307 // change it for your server port
    db.DatabaseName = "somedbname"
    db.UserName = "someuser"
    db.Password = "somepassword"
    
    If db.Connect Then
    
      Dim rs As RecordSet = db.SQLSelect("select @@Global.version AS Version")
    
      If rs <> Nil And not rs.Eof Then mySQLversion = rs.Field("Version").StringValue
    
    End If
    
    // Here mySQLversion contains the version or “Error”

    Original code found at https://blog.xojo.com/2018/05/14/getting-the-mysql-server-version/ :

    Dim db As New MySQLCommunityServer
    
    db.Host = "somehost"
    db.port = <port # for your mysql server>
    db.DatabaseName = "somedbname"
    db.UserName = "someuser"
    db.Password = "somepassword"
    
    If db.Connect Then
    
      Dim rs As RecordSet = db.SQLSelect("select @@Global.version")
    
      While rs <> Nil And rs.eof <> True
    
        // and here you get a row with the value selected
    
        rs.MoveNext
    
      Wend
    End If

or Sign Up to reply!