Delphi6 's new dbexpress is specifically designed to deal with databases such as mysql,db2,interbase,oracle, and when used, take care to copy Libmysql.dll to the current directory or system directory (98:SYSTEM,NT:SYSTEM32) and ensure that your 3306 ports are connected to the remote server.
SOURCE program:
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Dbxpress, DB, sqlexpr, Stdctrls, Comctrls, FMTBCD, Grids,
Dbgrids, Provider, Dbclient, dblocal, Dblocals, dbtables;
Type
TForm1 = Class (Tform)
Sqlconnection:tsqlconnection;
Statusbar1:tstatusbar;
Label1:tlabel;
Datasource1:tdatasource;
Dbgrid1:tdbgrid;
Groupbox1:tgroupbox;
Label2:tlabel;
Password:tedit;
User_name:tedit;
Hostname:tedit;
Label3:tlabel;
Label4:tlabel;
Button1:tbutton;
Groupbox2:tgroupbox;
Label5:tlabel;
Esql:tedit;
Label6:tlabel;
Database:tedit;
Buttongo:tbutton;
Sqlclientdataset:tsqlclientdataset;
Procedure Button1Click (Sender:tobject);
Procedure Buttongoclick (Sender:tobject);
Procedure Formclose (Sender:tobject; var action:tcloseaction);
Private
{Private declarations}
Public
{Public declarations}
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Procedure Tform1.button1click (Sender:tobject);
Begin
With SqlConnection do
Begin
Close;
params.values[' HostName ']:=hostname.text;
params.values[' UserName ']:=user_name.text;
params.values[' Password ']:=password.text;
params.values[' Database ']:=database.text;
Try
Connected:=true;
Statusbar1.panels[0]. text:= ' Connect OK ';
Buttongo.enabled:=true;
Except
Messagedlg (' Connect Error ', mterror,[mbyes],0);
End
End
End
Procedure Tform1.buttongoclick (Sender:tobject);
Begin
With Sqlclientdataset do
Begin
Close;
Commandtext:=esql. Text;
Open;
End
End
Procedure Tform1.formclose (Sender:tobject; var action:tcloseaction);
Begin
Sqlconnection.close;
End
End.