InterBase ToGo with dbExpress

From RAD Studio
Jump to: navigation, search

Go Up to Developing Database Applications

Starting with XE3, RAD Studio provides support for InterBase ToGo databases.

What has changed

Starting with XE3, RAD Studio enhances the dbExpress framework by adding an InterBase ToGo-specific driver. This change makes it easier for users to establish connections to InterBase ToGo databases using dbExpress, in Delphi and C++ applications.

Using the InterBase ToGo Driver

The InterBase ToGo driver can be used only at run time.

If you activate a connection at design time using InterBase ToGo or have an open InterBase ToGo connection in your Data Explorer, and try to run your application, you will get an error at run time. This happens because the InterBase ToGo server license requires exclusive access to the database. Since you already have an open connection at design time, you cannot then open a local connection to the same database in the application you are building/running. InterBase ToGo is intended to be only a deployment option and should not be used in the IDE or in the Data Explorer.

Therefore, at design time and in the Data Explorer, the full InterBase client should be used.

Example

The following example is a tutorial on how to establish a connection to an InterBase ToGo database in a Delphi VCL Forms Application:

Steps

  1. Select File > New > VCL Forms Application - Delphi.
  2. Add the following components to the form:
  3. Add the following code to the OnClick event handler for the connectButton.
procedure TForm1.connectButtonClick(Sender: TObject);
begin
  // create a new TSQLConnection object
  SQLConnection1 := TSQLConnection.Create(nil);
  // set the driver of the TSQLConnection control
  SQLConnection1.DriverName := 'IBToGo';
  // add the Database parameter to Params
  SQLConnection1.Params.Add('Database=full_path_to_your_database_file');
  // set the Username and Password parameters
  SQLConnection1.Params.Add('User_Name=SYSDBA');
  SQLConnection1.Params.Add('Password=masterkey');
  try
    // open the connection
    SQLConnection1.Open;
    Memo1.Text := 'Connection established';
  except
    on E: Exception do
      Memo1.Text := 'Exception raised with message : ' + #13#10 + E.Message;
  end;
end;

See Also