Here are my way of finding the current database server and database name for both Classic Client and RTC Client.
[code htmlscript=”false”]IF ISSERVICETIER THEN BEGIN
IF ISCLEAR(DomDoc) THEN
CREATE(DomDoc);
DomDoc.load(APPLICATIONPATH + ‘CustomSettings.config’);
DomNode :=
DomDoc.selectSingleNode(
‘//appSettings/add[@key=”DatabaseServer”]’);
MyServerName := DomNode.attributes.item(1).text;
DomNode :=
DomDoc.selectSingleNode(
‘//appSettings/add[@key=”DatabaseName”]’);
MyDatabaseName := DomNode.attributes.item(1).text;
END ELSE BEGIN
MyServer.SETRANGE("My Server",TRUE);
MyServer.FINDFIRST;
MyServerName := MyServer."Server Name";
MyDatabase.SETRANGE("My Database",TRUE);
MyDatabase.FINDFIRST;
MyDatabaseName := MyDatabase."Database Name";
END;[/code]
The Global Variables are
Name | DataType | Subtype | Length |
DomDoc | Automation | ‘Microsoft XML, v6.0’.DOMDocument | |
DomNode | Automation | ‘Microsoft XML, v6.0’.IXMLDOMNode | |
MyServerName | Text | 50 | |
MyDatabaseName | Text | 50 |