Set up an SQL connection in Ninox
- 1.Request a license file from Ninox for your Private Cloud or On-Premises that is granted
full access
for one of these Enterprise features:mssqlConnections
orpgConnections
. - 2.Install the license file on your Private Cloud or On-Premises.
- 3.Get the following environment variables from your SQL Server:
- 1.Server name:
MSSQL_SERVER
, e.g.,mssqltest1.database.windows.net
- 2.Database name:
DB_NAME
, e.g.,mssql-test.ninoxdb.de
- 3.Server admin:
MSSQL_SA
, e.g.,nx-testsqlserver-admin
- 4.Password:
MSSQL_SA_PASSWORD
Once you install the appropriate license file, the tab SQL Connections becomes visible in the Server Administration section in your Private Cloud or On-Premises.
- 1.Log in to your Private Cloud or On-Premises.
- 2.In Ninox, click the gear iconto access the global settings, then select Server Administration from the dropdown menu.
- 3.Click the SQL Connections tab, then click Create New Connection.
- 4.
- 1.Name: enter a new name for this connection
- 2.Connection Type: select MS SQL Server from the dropdown menu
- 3.Active: tick the checkbox to set to
true
- 4.
- 5.Database: e.g.,
mssql-test.ninoxdb.de
- 6.
- 7.
- 8.Encrypted: tick the checkbox to set to
true
- 5.Click the Save and Restart button.

Since we are using our own Ninox Private Cloud and SQL Server data in the validation steps, your results may look different than the ones below.
To validate the SQL connection, we are using a sample database that contains 1 table, 1 sub-table, and 3 fields:
SQL Connections
: a tableConnection name
: a text field to enter the name of the SQL connection
SQL Tests
: a sub-tableSQL Query or Command
: a text field to enter an SQL query or commandResult or Error
: a multiline text field to receive the result of the SQL query or command
Add a button, then add the following script that is triggered on click:
1
do as server
2
'Result or Error' := formatJSON(sendCommand('SQL Connections'.'Connection name', 'SQL Query or Command'))
3
end
In the sub-table
SQL Tests
, add a new record to run the following command in the SQL Query or Command field (1):1
SELECT 1
Click the sendCommand button (2). The following result appears in the Result or Error field (3):
{"result":{"recordsets":[[{"":1}]],"recordset":[{"":1}],"output":{},"rowsAffected":[1]}}

Add a button, then add the following script that is triggered on click:
1
do as server
2
'Result or Error' := formatJSON(queryConnection('SQL Connections'.'Connection name', 'SQL Query or Command'))
3
end
In the sub-table
SQL Tests
, add a new record to run the following command in the SQL Query or Command field (1):1
SELECT 1
Click the queryConnection button (2) to return actual record data. The following result appears in the Result or Error field (3):
{"result":[{"":1}]}

Last modified 8mo ago