Possible database connection problem

Everything else that doesn't fall into one of the other PB categories.
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 274
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Possible database connection problem

Post 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?
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Possible database connection problem

Post 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.
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 274
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Re: Possible database connection problem

Post 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?
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Possible database connection problem

Post by Fred »

You took the right dll version (x64 or x86) ? It really looks like this issue if it work within the IDE
User avatar
NicTheQuick
Addict
Addict
Posts: 1503
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Possible database connection problem

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 274
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Re: Possible database connection problem

Post 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.
Post Reply