Gambas Connection With MYSQL

Starting from the complaints of my friend named Hadyan A.K.A X-n1nj4 that he could not make the connection with MySQL database on gambas, then my answer is very easy to make a connection. Now I prove my words to my friend and also hopefully be encouraging to other who are looking for solutions into visual programming in linux other than java, or maybe for everyone previously are developer of Visual Basic, and then want to switch to visual programming under Linux , Gambas is a solution: D.
Let try.....

  1. Make a stand-alone procedure, if still a beginner stage, can be positioned at the top of all the existing syntax

PRIVATE koneksi AS Connection
PUBLIC rst AS Result


This means that connection name that we will create the connection, perhaps for my friends who already know PHP programming, well this procedure a little like php, where we usually make the connection. For example koneksi.php that contains command of connection to the database, but here there is little difference

Public rst as result. rst is name of the result, if you would like to change with another name, no problem


    2. Write a command to a database connection into form load. When form load code at first time in the form directly connect to the database

PUBLIC SUB Form_Open() 'event ketika form dibuka/hidup
koneksi = NEW Connection 'nama koneksi yang sudah kita buat diatas
koneksi.Type = "mysql" 'nama database
koneksi.Host = "localhost" 'hostname dari database
koneksi.Login = "root" 'nama user database
koneksi.Password = "gambas" 'password dari database
koneksi.Name = "perpus" 'nama database
koneksi.Open 'koneksi dibuka
end 'akhir perintah



That is the way to connect with a MySQL database from Gambas, easy right?



See you next ditutorial ....

0 comments:

Post a Comment