Page 1 of 1

Possible database connection problem

Posted: Fri Apr 04, 2025 9:38 am
by DeanH
I don't know if this is a bug or something I am doing wrong, but I have stumbled on something a bit strange.

I have MariaDB installed and working on my PC. I found if I tried to just connect when running the program in the IDE, it works. I get a connection value. I can then create a database and use it. But if I compile it to a stand-alone exe, then run the exe from either a command window or File Explorer, it returns 0 and does not connect. The parameters are correct.

Code: Select all

; UsePostgreSQLDatabase()
UseMySQLDatabase()
Define connection
; connection=OpenDatabase(#PB_Any,"host=DEANS port=5432","postgres","postgres",#PB_Database_PostgreSQL)	;this works compiled
connection=OpenDatabase(#PB_Any,"host=DEANS port=3306 dbname=mysql","root","mariadb",#PB_Database_MySQL) ;this does not work compiles
MessageRequester("Database",Str(connection))
End

I also have Postgresql installed and tried that. It connects correctly when compiled.

I am baffled. Anyone have an idea why the MariaDB connection returns 0 when compiled?

Re: Possible database connection problem

Posted: Fri Apr 04, 2025 9:46 am
by Fred
mysql needs an external DLL because it's LGPL licensed, as decribed here: https://www.purebasic.com/documentation ... abase.html . You can find it in the compiler directory.

Re: Possible database connection problem

Posted: Fri Apr 04, 2025 10:37 am
by DeanH
I made sure libmariadb.dll is in the same folder as the exe as indicated in the documentation. I even tried including it in UseMySQLDatabase(). Made no difference. Is there something else?

Re: Possible database connection problem

Posted: Fri Apr 04, 2025 10:49 am
by Fred
You took the right dll version (x64 or x86) ? It really looks like this issue if it work within the IDE

Re: Possible database connection problem

Posted: Fri Apr 04, 2025 1:07 pm
by NicTheQuick
It could also be a firewall or antivirus thing. Maybe you have all your compilations on a whitelist but not the standalone executable.

Re: Possible database connection problem

Posted: Fri Apr 04, 2025 9:56 pm
by DeanH
I worked it out. Wasn't a firewall issue. Turned out to be an old version of libmariadb.dll. This morning, I noticed a 2019 date on that file. I copied the latest from PB6.21 Beta4 into the folder and the test exe then returned a value. As I suspected, not a bug. It must have been there since PB5.70.