In the last post, i show you how to Install. Now i wanna try to show you “How make connection to MySql with this Component.
1.Run Your Delphi Application
2.In Component Pallete find Zeos Access ( you can use left arrow and right arrow to navigate this )
3.Drag and drop component
—> Choose Zconnection:TZConnection, you can named this component as you like, ex: MyConn
Ok! for use the component and drop to your Form Design has finish.
Now for next step
1.Click twice your Form Design, you will find
procedure TForm1.FormCreate(Sender: TObject); [type or paste the code here] end.
Insert this code in [type or paste the code here]
ShortDateFormat:='dd/mm/yyyy';
DecimalSeparator:='.';
myConn.Protocol:='mysql';
myConn.HostName:='localhost';
myConn.Port:=StrToInt('3306');
myConn.User:='[your user name to login MySql, default is root]';
myConn.Password:='[your password, but if you uses Zeos you must empty you password to login MySql]';
myConn.Database:='[your database]';
try
myConn.Connect;
except on E:exception do
begin
MessageDlg('Koneksi database gagal!!!'#13+E.Message, mtError,[mbOk],1);
Close;
end;
end;
end;
Save your project, and put libmysql40.dll[default included in your Zeos Package] in directory which contain your .exe file. Now compile your application or push F9.
You can follow any responses of
Make Easy Connection to MySqlby through RSS 2.0 feed. You can leave a response, i will appreciate if you give the comment, or trackback from your own site.2 Responses to “Make Easy Connection to MySql”
Please Insert Your Comment
#1
SyamSyah
24 Mei 2008 at 2:14 pmTalk From :
Delphier juga nihh… banyak2 posting delphi yaa… aq mo blajar ma yg udah ahli
#2
thevemo™
27 Mei 2008 at 11:53 amTalk From :
saya masih amatir mas…gimana kalo saya yang belajar linux