Can a new Storage table be created at run time?
Solution:
Yes; to do so, there are two possibilities.
The first one is to use Activate and Deactivate methods, which respectively activate and deactivate an object when a previous setup must be performed (initializing properties, for example), or when you need to perform tests where the object cannot be present and active.
The second possibility is to use StartAcquisition and StopAcquisition methods, which respectively start and stop the generation of data going to the Database. The Storage receives notifications on which registered tags underwent changes, and when this happens it checks whether these changes will be recorded or not. When this method is called, both change notification and record generation are stopped.
From these two events, you can create a new table via Storage’s TableName property, which must be changed after the execution of the method that deactivates communication with the database.
Examples:
Application.GetObject(“Storage1”).Deactivate()
Application.GetObject(“Storage1”).TableName = “Tabela”& Minute(now)
Application.GetObject(“Storage1”).Activate()
OR
Application.GetObject(“Storage1”).StopAcquisition()
Application.GetObject(“Storage1”).TableName = “Tabela”& Minute(now)
Application.GetObject(“Storage1”).StartAcquisition()