Topic: [Script] How to connect to MySQL using script
Example, how to connect to MySQL server using script.
procedure Form1_OnShow (Sender: string; Action: string);
begin
frmWait.Show;
Application.ProcessMessages;
{$MySQL disable_connectdialog}
Form1.MySQLConnection.Server := '127.0.0.1';
Form1.MySQLConnection.Port := 3306;
Form1.MySQLConnection.Username := 'root';
Form1.MySQLConnection.Password := 'root';
Form1.MySQLConnection.Database := 'mvd';
try
Form1.MySQLConnection.Connect;
except
frmWait.Close;
ShowMessage('Can''t connect to database.');
Form1.Close;
end;
if Form1.MySQLConnection.Connected then
begin
UpdateDatabase(''); // to fill ComboBoxes
Form1.GridEmployees.dbUpdate; // if you have TableGrid on first form with option "Enable auto execution", you should call method dbUpdate manually
end;
frmWait.Close;
end;
begin
end.
Download project:
http://myvisualdatabase.com/forum/misc. … download=1