|
AnyDAC
|
Adds private connection definition.
|
Parameters |
Description |
|
const AName: string |
A connection definition name. |
|
const ADriver: string |
A driver ID. |
|
AList: TStrings |
A list of parameter name=value pairs. |
|
APersistent: Boolean = False |
A persistence flag. By default is False. |
The AddConnectionDef method adds new private or persistent connection definition to the ConnectionDefs list.
The connection definition will get name AName, DriverID ADriver and parameters AList. The name must be unique across other connection definitions in the ConnectionDefs list, otherwise exception will be raised.
Set APersistent to True, to mark connection definition as persistent, otherwise it will be private one. After the call a persistent connection definition is not stored to a file. Call SaveConnectionDefFile to save this and other changes to a file. Not stored connection definitions will be discarded after AnyDAC manager or application will be terminated.
After connection definition is added, it may be referenced by TADCustomConnection.ConnectionDefName.
procedure AddConnectionDef(const AName: string; const ADriver: string; AList: TStrings; APersistent: Boolean = False);
Defining Connection, ConnectionDefs, SaveConnectionDefFile, DeleteConnectionDef, ModifyConnectionDef, IADStanConnectionDefs.AddConnectionDef, TADCustomConnection.ConnectionDefName
var
oList: TStringList;
......
oList := TStringList.Create;
oList.Add('Server=127.0.0.1');
oList.Add('Database=addemo');
ADManager.AddConnectionDef('myconn', 'MySQL', oList);
......
ADConnection1.ConnectionDefName := 'myconn';
ADConnection1.Connected := True;|
What do you think about this topic? Send feedback!
|