CX-Supervisor Script To Modify A CX-Supervisor DB Connection

Modified on Sun, 11 May, 2025 at 10:33 PM

CX-Supervisor allows you to modify the database connection from within a script. This can be done using the DBExecute command as shown in the following example:
 
dbeSuccess = DBExecute ([myDatabaseConnection], "Connection", [database reference], {User Name}, {Password})
 
Where:
 
dbeSuccess = the success of the command
[myDatabaseConnection] = The database connection in CX-Supervisor
"Connection" = The command we are using on the database - do not change this
[database reference] = The reference to the database file (e.g. Microsoft Access .accdb file) or File DSN (.dsn) on the disk
{User Name} = Optional User name for a password protected MDB file
{Password} = Optional password for a password protected MDB file
 
It should be noted that this command does NOT take a replacement connection string as a parameter, it creates a new connection string from the parameters provided.
 
If using an mdb, accdb or other database file as the {database reference} parameter, CX-Supervisor runtime will select an appropriate installed driver for that database and create a connection string.
 
If using a File DSN, simply supply the path and filename of the FileDSN as the {database reference} parameter.
 
If your database is accdb and uses password protection or you use a workgroup or system database, you must create a File DSN containing the correct parameters and switch between DSN files rather than between Access Database files.
 
For details of supported databases in CX-Supervisor and further information on their use, consult Section 12 of the Manual - Databases. Additionally, remember that CX-Supervisor Machine Edition has support for just the Microsoft Access Database (.mdb and .accdb), if you need to use a File DSN you must upgrade to PLUS Edition.

Example:

newConnection = "Recipe5.accdb"
DBExecute "Recipe", "Connection", newConnection

Changes the Recipe database to 'Recipe5.accdb'

newConnection = "machine1.dsn"
DBExecute "MachineDetails", "Connection", newConnection

Changes the Machine details database to be whatever is referred to in the File DSN.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article