Compiled Windows Console EXE cannot connect to mysql anymore

Just starting out? Need help? Post your questions and find answers here.
lesserpanda
User
User
Posts: 65
Joined: Tue Feb 11, 2020 7:50 am

Compiled Windows Console EXE cannot connect to mysql anymore

Post by lesserpanda »

Hello guys,

So I've been developing an app which goes to MYSQL and gets records etc. In Dev environment, it works fine. (Windows 11). After which when I compile it to a Console App (compiler option), the database does not connect anymore.
Am I doing something wrong? Do I need to include or install a MYSQL library or something? I thought it may be the dev environment so I installed PB on the win 2016 server I was deploying to, ran it in Dev and it was fine. Ran it as exe and same issue.

Say the following code...

Code: Select all

UseMySQLDatabase()
DBConn = OpenDatabase(#PB_Any, "host=127.0.0.1 port=28177 dbname=mydb", "root", "SNIP", #PB_Database_MySQL)
If Not DBConn
  PrintN(DatabaseError())
  Debug(DatabaseError())
EndIf

Debug("Hello")
If OpenConsole()
  PrintN("Hello")
  SqlStr.s = "select count(*) from orders"
  If DatabaseQuery(DBConn, SqlStr)
    While NextDatabaseRow(DBConn)
      Total.l = GetDatabaseLong(DBConn, 0)
      Debug("Total Records: " + Str(Total))
      PrintN("Total Records: " + Str(Total))
    Wend
    FinishDatabaseQuery(DBConn)
    CloseDatabase(DBConn) 
  Else
    PrintN(DatabaseError())
    Debug(DatabaseError())
  EndIf
  CloseConsole()
EndIf
It works fine in Dev but when you compile it into a exe and run it from cmd line, it just fails silently without any error.

Any advice?
Thanks
lesserpanda
User
User
Posts: 65
Joined: Tue Feb 11, 2020 7:50 am

Re: Compiled Windows Console EXE cannot connect to mysql anymore

Post by lesserpanda »

viewtopic.php?t=79522

Extra searching the forum worked. Thanks.
Oso
Enthusiast
Enthusiast
Posts: 595
Joined: Wed Jul 20, 2022 10:09 am

Re: Compiled Windows Console EXE cannot connect to mysql anymore

Post by Oso »

lesserpanda wrote: Wed Nov 30, 2022 2:08 pm Extra searching the forum worked. Thanks.
I was just about to reply and mention the solution in that thread, which was in response to mine from July. Your post rang some bells with me and I think I had only been using PureBasic for a few days when I encountered the same as you did. Glad that you found it anyway :D
Post Reply