procedure TDM_Principal.SQLConnection1BeforeConnect(Sender: TObject);
var
arq_conexao: TiniFile;
path,
banco,
arquivo,
p_banco: String;
begin
conexao := Sqlconnection1;
path := ExtractFilePath(Application.ExeName);
arquivo := path + ExtractFileName('Conexao_Global.ini');
arq_conexao := TIniFile.Create(arquivo);
banco := arq_conexao.ReadString('conexao_atual','banco_atual','');
p_banco := arq_conexao.ReadString('conexao_atual','path_banco','');
if banco = 'SqlServer' then
begin
SqlConnection1.ConnectionName := 'Mairibel';
SqlConnection1.DriverName := 'MSSQL';
SqlConnection1.GetDriverFunc := 'getSQLDriverMSSQL';
SqlConnection1.LibraryName := 'dbxmss30.dll';
SqlConnection1.LoginPrompt := False;
SqlConnection1.VendorLib := 'OleDb';
SqlConnection1.Params.Values['DriverName'] := arq_conexao.ReadString('SqlServer','DriverName','');
SqlConnection1.Params.Values['HostName'] := arq_conexao.ReadString('SqlServer','HostName','');
SqlConnection1.Params.Values['DataBase'] := arq_conexao.ReadString('SqlServer','DataBase','');
SqlConnection1.Params.Values['User_Name'] := arq_conexao.ReadString('SqlServer','User_Name','');
SqlConnection1.Params.Values['Password'] := arq_conexao.ReadString('SqlServer','password','');
SqlConnection1.Params.Values['OS Authentication'] := arq_conexao.ReadString('SqlServer','OS Authentication','');
end
else
if banco = 'MySql' then
begin
SqlConnection1.ConnectionName := 'MYSQLCONNECTION';
SqlConnection1.DriverName := 'MySQL';
SqlConnection1.GetDriverFunc := 'getSQLDriverMYSQL';
SqlConnection1.LibraryName := 'dbxmys30.dll';
SqlConnection1.LoginPrompt := False;
SqlConnection1.VendorLib := 'LIBMYSQL.dll';
SqlConnection1.Params.Values['DriverName'] := arq_conexao.ReadString('MySql','DriverName','');
SqlConnection1.Params.Values['HostName'] := arq_conexao.ReadString('MySql','HostName','');
SqlConnection1.Params.Values['DataBase'] := arq_conexao.ReadString('MySql','DataBase','');
SqlConnection1.Params.Values['User_Name'] := arq_conexao.ReadString('MySql','User_Name','');
SqlConnection1.Params.Values['Password'] := arq_conexao.ReadString('MySql','password','');
end
else
if banco = 'FireBird' then
begin
SqlConnection1.ConnectionName := 'Mairibel_FB';
SqlConnection1.DriverName := 'Interbase';
SqlConnection1.GetDriverFunc := 'getSQLDriverINTERBASE';
SqlConnection1.LibraryName := 'dbxint30.dll';
SqlConnection1.LoginPrompt := False;
SqlConnection1.VendorLib := 'GDS32.DLL';
SqlConnection1.Params.Values['DriverName'] := arq_conexao.ReadString('FireBird','DriverName','');
SqlConnection1.Params.Values['HostName'] := arq_conexao.ReadString('FireBird','HostName','');
SqlConnection1.Params.Values['DataBase'] := arq_conexao.ReadString('FireBird','DataBase','');
SqlConnection1.Params.Values['User_Name'] := arq_conexao.ReadString('FireBird','User_Name','');
SqlConnection1.Params.Values['Password'] := arq_conexao.ReadString('FireBird','password','');
end;
end;
end.