Connection String Builder
Constructs database connection strings from individual parameters. Supports SQL Server (Windows Auth and SQL Auth), Oracle, MySQL, and generic ODBC.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Problem this solves
Connection string syntax errors are a frequent forum question.
Cross-references: REST API POST Caller Pattern 1 for OAuth2 token retrieval if your database uses Azure AD auth. Config File Reader for loading connection parameters from a JSON config file.
1SQL Server — Windows Authentication (Trusted)
Uses the PAD runner's Windows identity. No username/password needed. Most common in enterprise environments where the service account has database access.
Variables: varServer (SQL Server hostname or IP), varDatabase (database name), varCurrentMessage (logging), varConnectionString (output — connection string)
2SQL Server — SQL Authentication
Uses a SQL Server login with username and password. Always pull credentials from Key Vault in production.
Variables: varServer (SQL Server hostname), varDatabase (database name), varDbUsername (SQL login username), varDbPassword (SQL login password — use Key Vault), varCurrentMessage (logging), varConnectionString (output)
3SQL Server — Named Instance with Port
Connects to a named SQL Server instance on a non-default port.
Variables: varServer (server hostname), varInstance (instance name), varPort (port number), varDatabase (database name), varCurrentMessage (logging), varConnectionString (output)
4Oracle — TNS Name
Connects to an Oracle database using a TNS name configured in tnsnames.ora.
Variables: varTnsName (Oracle TNS name), varOracleUser (Oracle username), varOraclePassword (Oracle password), varCurrentMessage (logging), varConnectionString (output)
5ODBC — Generic DSN
Uses a pre-configured ODBC Data Source Name (DSN). The DSN is set up in Windows ODBC Data Source Administrator.
Variables: varDsnName (ODBC DSN name), varOdbcUser (username — empty for Windows Auth DSNs), varOdbcPassword (password), varCurrentMessage (logging), varConnectionString (output)
6Test Connection via PowerShell
Tests the connection string by opening and immediately closing a SQL connection. Returns success or error. Use this to validate the connection string before running queries.
Variables: varConnectionString (connection string from any pattern above), varCurrentMessage (logging), varTestOutput (PowerShell output), varTestError (PowerShell error)
Variable Reference Summary
| Variable | Type | Used In | Purpose |
| `varServer` | Text | Patterns 1–3 | SQL Server hostname/IP |
| `varDatabase` | Text | Patterns 1–3 | Database name |
| `varDbUsername` | Text | Pattern 2 | SQL login username |
| `varDbPassword` | Text | Pattern 2 | SQL login password |
| `varInstance` | Text | Pattern 3 | SQL Server named instance |
| `varPort` | Text | Pattern 3 | SQL Server port |
| `varTnsName` | Text | Pattern 4 | Oracle TNS name |
| `varOracleUser` | Text | Pattern 4 | Oracle username |
| `varOraclePassword` | Text | Pattern 4 | Oracle password |
| `varDsnName` | Text | Pattern 5 | ODBC DSN name |
| `varOdbcUser` | Text | Pattern 5 | ODBC username |
| `varOdbcPassword` | Text | Pattern 5 | ODBC password |
| `varConnectionString` | Text | All patterns | Output connection string |
| `varCurrentMessage` | Text | All patterns | Logging message for Subflow_Logging |
| `varTestOutput` | Text | Pattern 6 | PowerShell test result |
| `varTestError` | Text | Pattern 6 | PowerShell test error |
Notes
- Credentials in production. Patterns 2, 4, and 5 use placeholder passwords. Always retrieve from Azure Key Vault or Dataverse config table. Never store database credentials in PAD flow variables visible in the designer.
- Windows Auth (Pattern 1) is preferred. No credentials to manage — the PAD runner's service account authenticates directly. Requires the service account to have a SQL login and appropriate database permissions.
- Named instance backslash (Pattern 3). Inside
$fx'...', a single\\\\produces a literal backslash. The connection stringServer=host\\INSTANCEbecomes$fx'...${varServer}\\\\${varInstance}...'. - Pattern 6 test uses SqlClient. This works for SQL Server. For Oracle, replace
SqlClient.SqlConnectionwithOracleClient.OracleConnection(requires Oracle client installed). For ODBC, useOdbc.OdbcConnection. - No ON ERROR on SET. Connection string building is pure string concatenation — no error handling needed. Pattern 6 (test connection) has ON ERROR on the PowerShell action.
Dependencies
- Config File Reader