Show: Delphi C++
Display Preferences

FireDAC.Comp.Client.TFDCustomManager.AddConnectionDef

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure AddConnectionDef(const AName, ADriver: string; AList: TStrings = nil;  APersistent: Boolean = False);

C++

void __fastcall AddConnectionDef(const System::UnicodeString AName, const System::UnicodeString ADriver, System::Classes::TStrings* AList = (System::Classes::TStrings*)(0x0), bool APersistent = false);

Properties

Type Visibility Source Unit Parent
procedure
function
public
FireDAC.Comp.Client.pas
FireDAC.Comp.Client.hpp
FireDAC.Comp.Client TFDCustomManager

Description

Adds the private connection definition.

The AddConnectionDef method adds a new private or persistent connection definition to the ConnectionDefs list. 

The connection definition gets the name AName, the DriverID ADriver, and the parameters AList. The name must be unique across other connection definitions in the ConnectionDefs list, otherwise an exception is raised. 

Set APersistent to True, to mark the connection definition as persistent, otherwise this will be private. After a call, the persistent connection definition is not stored into a file. Call SaveConnectionDefFile to save this and other changes into a file. The connection definitions that are not stored will be discarded after the FireDAC manager or the application are terminated. 

After a connection definition is added, it can be referenced by TFDCustomConnection.ConnectionDefName.

Example

var
  oList: TStringList;
......
  oList := TStringList.Create;
  oList.Add('Server=127.0.0.1');
  oList.Add('Database=addemo');
  FDManager.AddConnectionDef('myconn', 'MySQL', oList);
......
  FDConnection1.ConnectionDefName := 'myconn';
  FDConnection1.Connected := True;

See Also

Samples

Personal tools
In Other Languages
Previous Versions
Assistance