Industrial Automation
Industrial Automation | Europe

myKnowledge

Main > Product Type > Software > Visualisation
Minimize Text   Default    Enlarge Text
 

Print
E-mail

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


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.




Comments (View All Comments / Add Comment)

Related Articles
No related articles found.
Created 2013-01-28
Modified 2013-02-19
Views 3923

 

You are not logged in.