Wednesday, 17 July 2013

Connection String with Firebird database in Delphi XE2

procedure TForm1.Button1Click(Sender: TObject);
var 
 Conn: TSQLConnection;
begin
  Conn := TSQLConnection.Create(Self);
  try
    Conn.DriverName := 'Provider=MSDASQL.1; '+
                       'Persist Security Info=False; '+
                       'Data Source=DataBaseName; '+
                       'Initial Catalog=DataBaseName';'; 
    Conn.Params.Add('User_Name=SYSDBA');
    Conn.Params.Add('Password=masterkey');

    // Replace the dbname in the next line with the
    // value obtained at runtime, as  in
    // Conn.Params.Add('Database=' + YourNewPathAndDBName);
    Conn.Params.Add('Database=D:\FolderName\DataBaseName.fdb');

    Conn.Open;
    if Conn.Connected then
      ShowMessage('Connection successfully made to DB');
  finally
    Conn.Free;
  end;
end;

No comments:

Post a Comment