Hi Guys,
i want to connect to a mysql database and manage it with the pb-included Database commands. I already used the search in the german and in the english forum, but there was no entry that worked with PureBasic 4.20.
I hope, you can help me.
Thanks in advance,
PBUser
MySQL and the PB Database commands?
Install MyODBC 3.51
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Yes this should work on Vista.
ODBC is the Microsoft Database Layer, so it would be seriously bad if it doesn't , but i did not test (successfully tested on 2K, XP, 2K3 Server).
Once MyODBC is installed, you have to configure (manually or programmaticaly) a database connection.
for that, follow instructions :
1/
start -> execute -> odbcad32.exe
2/
make sure you have MySQL ODBC 3.51 Driver in 'ODBC Driver' page
3/
system data source -> add -> select MyODBC
4/
Data Source Name = test
Description =
Server = localhost (or external hosts/IP but make sure port 3306 is opened, so check your firewall and mysql user/rights)
User = root
Password =
Database = mysql
5/
click on 'test' button to check if connection is ok
6/
ok your odbc connection is ready, now let's see what to do inside purebasic
7/
just execute this sample :
ODBC is the Microsoft Database Layer, so it would be seriously bad if it doesn't , but i did not test (successfully tested on 2K, XP, 2K3 Server).
Once MyODBC is installed, you have to configure (manually or programmaticaly) a database connection.
for that, follow instructions :
1/
start -> execute -> odbcad32.exe
2/
make sure you have MySQL ODBC 3.51 Driver in 'ODBC Driver' page
3/
system data source -> add -> select MyODBC
4/
Data Source Name = test
Description =
Server = localhost (or external hosts/IP but make sure port 3306 is opened, so check your firewall and mysql user/rights)
User = root
Password =
Database = mysql
5/
click on 'test' button to check if connection is ok
6/
ok your odbc connection is ready, now let's see what to do inside purebasic
7/
just execute this sample :
Code: Select all
;-------------------------------------------------------------------------
; Database Exemple for PureBasic 4.2x.
; This minimalist example require a 'test' data source.
; Data source must be first configured in the ODBC manager (odbcad32.exe).
;-------------------------------------------------------------------------
; Initialize the ODBC engine
If UseODBCDatabase()
; Connect to the MySQL database
If OpenDatabase(0, "test", "root", "")
; Execute a SQL query
If DatabaseQuery(0, "SELECT help_topic_id, name FROM mysql.help_topic")
; Fetching rows
While NextDatabaseRow(0)
Debug GetDatabaseString(0, 0) + " ==> " + GetDatabaseString(0, 1)
Wend
Else
MessageRequester("Error", "DatabaseQuery() failed !" + #CRLF$ + DatabaseError())
EndIf
; Once fetching done, closing opened database.
CloseDatabase(0)
Else
MessageRequester("Error", "OpenDatabase() failed !" + #CRLF$ + DatabaseError())
EndIf
Else
MessageRequester("Error", "UseODBCDatabase() failed !")
EndIf
End
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
and there's also very old tutorials here that i took years ago :
PB_SQL.zip
PB_SQL.zip
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer