Xojo 2016: WebApp crashed on Windows Server by rs.eof = false

Since Xojo 2016.1 [in 2016.2 is the same bug] my WebApp crash on Windows Server 2012.
In OS X and old versions of Xojo, everything runs fine.

I can reproduce the error:

New WebApp.
Drop a button to the WebApp.

And this code to the button:


  ' -----------------------------------------------------
  ' MySQL
  '------------------------------------------------------
  Dim db As MySQLCommunityServer
  db = New MySQLCommunityServer
  db.Host = "" // here ist the host ip, I delete it for the forum
  db.Port = 3306
  db.DatabaseName = "" // here ist the database name, I delete it for the forum
  db.UserName = "" // here ist the username , I delete it for the forum
  db.Password = ""// here ist the password, I delete it for the forum
  If db.Connect Then
     MsgBox("it works")
    db.SQLExecute("set names utf8")
  Else
    MsgBox("MySQL - Error: " + db.ErrorMessage )
  End If
  // ---------------------------------------------------
  
  
  DIM MZDaten_Archiv(99,3) As String
  DIM rs as RecordSet
  DIM count as integer
  rs = db.SQLSelect ("SELECT COUNT(projectno) FROM lines")
  if rs <> nil then 
    
    Dim i As Integer = 0 
    rs = db.SQLSelect ("SELECT projectno FROM lines  ORDER BY projectno ASC")  
    
    
    
     while rs.EOF = False    // <----- here the apps crashs
      // MZDaten_Archiv(i,0)  = (rs.IdxField(1).StringValue.DefineEncoding(Encodings.UTF8))  
      i = i +1
      rs.MoveNext
    wend
    
  else // end rs <>nil
    MsgBox (db.ErrorMessage)
  end if // rs is not nil

The App crash at the while rs.EOF = False line.

I commented out the next line, and the App crashs again. So the EOF makes trouble in Windows Server?

What can I do to solve it?

Try using the following:

while not rs.eof

rs = db.SQLSelect ("SELECT projectno FROM lines  ORDER BY projectno ASC")  

 <<<------------------ HERE YOU HAVE NOT CHECKED FOR RS = NIL

 while rs.EOF = False    // <----- here the apps crashs
  // MZDaten_Archiv(i,0)  = (rs.IdxField(1).StringValue.DefineEncoding(Encodings.UTF8))  
  i = i +1
  rs.MoveNext
wend

Well, there’s only one reason why RS would be nil and that’s because there was a database error.

ALWAYS check for error after every database operation.

[code]Dim i As Integer = 0
rs = db.SQLSelect (“SELECT projectno FROM lines ORDER BY projectno ASC”)
if db.error then
dim sErr as string = db.errormessage //Do something with this. Log it, show it to developer, whatever.
//have to return because rs WILL be nil.
Return
endif

 while rs.EOF = False[/code]

I understand your tip, but with Xojo 2015.4.1 everything works fine.

The second database query is the same, just with a sorting option. And the second one will only start, when there is no error from the first one. There is an other problem with 2016.x with MySQL and Windows. [Even with Mac and MySQL - everything is fine.]

Is your database connection persistent?

Right. So with 2016, the database is throwing an error now on the second query. Knowing what the error is would go a long way toward resolving it. Put in the error checking that Bob suggested and post the results.

@Bob: Yes the database connection is persistent: We use a server by “Freudenberg-IT”. [In Germany one of the best of the best hosters for SAP systems. Very expensive, but 99,99% uptime.] On this server there is only the MySQL-database and the compiled Xojo App, nothing else. No other Server-Services are running. No sharing of the Server with others. All Windows updates are done. And because 2015.4.x compilings working, and 2016.1, 2016.1.1 and 2016.2 have this problems, there must be a change in 2016.x.

@Tim: Good idea, I’ll try Bobs error checking.

update:

I used Bobs check and got this message:

“Lost connection to MySQL server during query”

I searched for this term in the Xojo forum, but didn’t find a match. :frowning:

I’ll try it again with different combinations:

Xojo 2015.4.0 on Windows Server 2012: works
Xojo 2015.4.1 on Windows Server 2012: works

Xojo 2016.1 on Windows Server 2012: “Lost connection to MySQL server during query”
Xojo 2016.1.1 on Windows Server 2012: “Lost connection to MySQL server during query”

Xojo 2016.2 32Bit on Windows Server 2012: “Lost connection to MySQL server during query”
Xojo 2016.2 64Bit on Windows Server 2012: “Lost connection to MySQL server during query”

Xojo 2016.1 @OS X: works
Xojo 2016.2 @ OS X: works

Same source code.

So something in Xojo 2016.x makes the troubles in combination with Windows. :frowning:

UPDATE with a workaround:

Fantastic news, I found a workaround :

I delete the MySQLCommunityPlugin.dll in the Xojo 2016.2 compiled Lib-folder, and copy & paste the MySQLCommunityPlugin.dll from the Xojo 2015.4.1 LIB Folder. Now it works.

I don’t know whats different between boths libs, the 2016 is double the size of the 2015 version. Will Xojo deliver a new updated .dll for 2016?

Great conversation! Got some tricks!

File a feedback report.

A co-worker does it:
<https://xojo.com/issue/44757>

Will Xojo fix something like this fast? So will there be a Xojo 2016.2.1? Or will I have to wait the usual 90 days for the next big update?

I know that there is something going on with Threads and Databases in 2016 R2.1 (in beta) but I have not been following it all that closely.

Hi Thomas, I’ve discovered recently that creating more than one recordset on a database connection can cause problems. In your example you should close the first recordset before assigning it to the new result from the 2nd query.

Do you have a Feedback report on this?

This may be a SQL Server only issue and is not a bug in Xojo. Have a look at this link:
Using Multiple Active Result Sets (MARS)

The MARS option is an ODBC option so may apply to MySQL. I have found that not closing one recordset before opening another on the same connection causes unexpected results.

Hope that helps.

  • Do not reuse rs as in your example for a second query, create a separate variable.
  • MySQL does not support MARs. So as Jim mentioned try with closing the first record set before executing the second query. Or create a separate connection for the second query.
  • The result of the first query is not used in your code anywhere, so you can remove the query and the outer loop.

Hmm. But with Xojo 2015.4.1 everything works.
With Xojo 2016.2.1 it does not work. With Xojo 2016.2.1 and the Mysql .dlls from Xojo 2015.4.1 it works.

So I don’t think that my source code have an error.