Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Querying metadata about Connection Definition Parameters



Permlink Replies: 3 - Last Post: Jan 3, 2017 11:35 PM Last Post By: Dmitry Arefiev
costa basil

Posts: 44
Registered: 4/8/08
Querying metadata about Connection Definition Parameters
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 30, 2016 1:15 AM
Hello:

Is there a metadata API in FireDac that allows one to query the following information:
1. The list of all supported driver ids, i.e. DB2, MSSQL, SQLite etc.
2. For each driver id, the list of all possible connection definition parameters as described here : http://docwiki.embarcadero.com/RADStudio/Berlin/en/Database_Connectivity_(FireDAC) . For instance, for MSSQL the connection definition parameters are described here: http://docwiki.embarcadero.com/RADStudio/Berlin/en/Connect_to_Microsoft_SQL_Server_(FireDAC) : server, port etc. I guess, I am trying to see if there is metadata api that can return an exhaustive list of all possible parameters for MSSQL. In FireDac Exporer, when you click on a connection definition you get on the right side, on the Definition tab all the parameters of that connection definition. Are they hard-coded or is there a way to retrieve the complete list using the FireDac api?

Thank
costa basil

Posts: 44
Registered: 4/8/08
Re: Querying metadata about Connection Definition Parameters
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 30, 2016 10:39 PM   in response to: costa basil in response to: costa basil
For #1, I found FireDAC.Comp.Client.TFDCustomManager.GetDriverNames, this, however, returns only the drivers I have added driver links for on my data module.
For #2, I found the following code in FireDAC.VCLUI.ConnEdit.pas (I removed the form name):
function IsDriverKnown(const ADrvID: String; out ADrvMeta:
    IFDPhysDriverMetadata): Boolean;
var
 i: Integer;
 oManMeta: IFDPhysManagerMetadata;
begin
  FDPhysManager.CreateMetadata(oManMeta);
  for i := 0 to oManMeta.DriverCount - 1 do
    if CompareText(oManMeta.DriverID[i], ADrvID) = 0 then begin
      oManMeta.CreateDriverMetadata(ADrvID, ADrvMeta);
      Result := True;
      Break;
    end;
end;
 
procedure GetDriverParams(const ADrvID: String; AStrs: TStrings);
var
  oDrvMeta: IFDPhysDriverMetadata;
  oTab: TFDDatSTable;
  i: Integer;
begin
  if IsDriverKnown(ADrvID, oDrvMeta) then begin
    oTab := oDrvMeta.GetConnParams(AStrs);
    try
      for i := 0 to oTab.Rows.Count - 1 do
        AStrs.Add(oTab.Rows[i].GetData('Name') + '=' + oTab.Rows[i].GetData('DefVal'));
    finally
      oTab.Destroy
    end;
  end;
end;
end
costa basil

Posts: 44
Registered: 4/8/08
Re: Querying metadata about Connection Definition Parameters
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 31, 2016 1:39 PM   in response to: costa basil in response to: costa basil
I would like to make one request though, could you please document the structure of the table returned by IFDPhysDriverMetadata.GetConnParams()? I was interested in the values in the Type column. From reading the code they seem to be:
@L - boolean (true/false)
@Y - Yes/No
@I - integer
@F[:<file filter>] - file
@S - string
@P - password
<value1>;..;<valueN> - <value1>, .., <valueN> are allowable values for the parameter. <label> is the label that should be displayed in the UI.

Any other permutations?
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Querying metadata about Connection Definition Parameters
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 3, 2017 11:35 PM   in response to: costa basil in response to: costa basil
I would like to make one request though, could you please document the structure of the table returned by IFDPhysDriverMetadata.GetConnParams()?

See TFDPhysDriver.GetConnParams for details.

Any other permutations?

No.

--
With best regards,
Dmitry
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02