Topic: How To Connnect MySQL Another Server And Cross Query ?

How To Connnect MySQL Another Server And Cross Query ?
In same time

Post's attachments

Attachment icon 2016-11-03 09 30 54.png 11.34 kb, 232 downloads since 2016-11-03 

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How To Connnect MySQL Another Server And Cross Query ?

Hello prahousefamily

If you want to run multiple MySQL servers, the simplest way is to compile the servers with different TCP / IP ports and socket files so they do not all listen to the same port or the same socket.

For more explanations, you could go to this link : (sorry, it's in french), but informations are very interesting

http://cipcnet.insa-lyon.fr/sqltut/nexe … rvers.html

Regards

JB

Re: How To Connnect MySQL Another Server And Cross Query ?

An example, how to populate grid from another MySQL server

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
var
    MySQL: TMyConnection;
begin
    MySQL := TMyConnection.Create(Form1);
    MySQL.Options.UseUnicode := True; 
    MySQL.Server := '10.10.10.10'; // ip address of MySQL server
    MySQL.Port := 3306;
    MySQL.Username := 'username';
    MySQL.Password := 'password';
    MySQL.Database := 'databasename';
    MySQL.LoginPromt := False;

    try
        MySQL.Connect;
    except
        ShowMessage('Can''t connect to database.');
    end;

    if MySQL.Connected then
    begin
       Form1.TableGrid2.dbMySQLConnection := MySQL;
       Form1.TableGrid2.dbSQL:='SELECT id, lastname, firstname FROM employees'; // the id field, want to be able to edit or delete the entry from the table component
       Form1.TableGrid2.dbGeneralTable := 'employees';
       Form1.TableGrid2.dbListFieldsNames :='delete_col,Фамилия,Имя';
       Form1.TableGrid2.dbSQLExecute;
       MySQL.Disconnect;
    end;


end;
Dmitry.

4 (edited by prahousefamily 2016-11-10 01:55:56)

Re: How To Connnect MySQL Another Server And Cross Query ?

Thank You Dmitry.And jean.brezhonek
Now Can use script query Two server .....
Thank you Again
https://s18.postimg.org/6s6q19cuh/2016_11_10_08_39_10.png

OPEN Code

procedure Form1_Button2_OnClick (Sender: string; var Cancel: boolean);
var
MySQL2: TMyConnection;
begin
    MySQL2 := TMyConnection.Create(Form1);
    MySQL2.Options.UseUnicode := True;
    MySQL2.Server := Form1.Edit6.Text ;
    MySQL2.Port := strtoint(Form1.Edit9.Text);
    MySQL2.Username := Form1.Edit7.Text;
    MySQL2.Password := Form1.Edit8.Text;
    MySQL2.Database := Form1.Edit10.Text;
    MySQL2.LoginPromt := False;
    try
        MySQL2.Connect;
        except
        ShowMessage('Can''t connect to database.');
    end;
    if MySQL2.Connected then
    begin
        Form1.TableGrid2.dbMySQLConnection := MySQL2;
        Form1.TableGrid2.dbSQL:='Show tables';
        Form1.TableGrid2.dbSQLExecute;
        MySQL2.Disconnect;
    end;
end;
procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
var
MySQL1: TMyConnection;
begin
    MySQL1 := TMyConnection.Create(Form1);
    MySQL1.Options.UseUnicode := True;
    MySQL1.Server := Form1.Edit1.Text ;
    MySQL1.Port := strtoint(Form1.Edit4.Text);
    MySQL1.Username := Form1.Edit2.Text;
    MySQL1.Password := Form1.Edit3.Text;
    MySQL1.Database := Form1.Edit5.Text;
    MySQL1.LoginPromt := False;
    try
        MySQL1.Connect;
        except
        ShowMessage('Can''t connect to database.');
    end;
    if MySQL1.Connected then
    begin
        Form1.TableGrid1.dbMySQLConnection := MySQL1;
        Form1.TableGrid1.dbSQL:='Show tables';
        Form1.TableGrid1.dbSQLExecute;
        MySQL1.Disconnect;
    end;
end;
begin
end.
Post's attachments

Attachment icon TwoServer.zip 5.07 kb, 413 downloads since 2016-11-10 

My Visual Database : I Love You
Easy For Beginner Student For Me