The openserverfile statement opens a database (used on the server).


This statement has one parameter:

database – name of database to open.


This statement opens a database on the server. When writing web publishing code, Panorama normally takes care of opening and closing databases on the server for you – in most situations, you don’t have to worry about it. When a web URL references a database, that database is automatically opened (if it isn’t open already).

However, in some situations your code will need to explictly open other databases. The most common situation where this is needed is when the codes needs access to information in another database, for example when using the related(, relatedarray(, lookup( or arraybuild( functions. These functions won’t work unless the target database is open. On the server, you can either configure a database to be opened automatically when the server starts up (using the File>Database Options>Server panel) or you can open a database as needed using the openserverfile statement. (The openserverfile statement is similar to the openfile and opendatabase statements, but is designed to be used on the server in web code. You cannot use the openfile and opendatabase statements in web code.)

The openserverfile statement has one parameter, the name of the database to open. Unlike the openfile and opendatabase statements, this parameter must be just the filename – you cannot specify any path or folder. This filename must be the name of the file on the server (which may be different than the name of the file on individual client computers).

The specified database will immediately open on the server. This is completely invisible, no window will be opened (this is different from Panorama 6, which would open the data sheet window). However, the specified database will become the active database, so you can start using it immediately. (If the database was already open, it will simply become active.)

openserverfile "Contacts"
// Contacts is open and active
//   setactivedatabase statement is not needed
field ID

If the specified database has an .InitializeServer procedure, that procedure will be run before the procedure continues. (However, if the database was already open, the .InitializeServer procedure will not run again.)

If a database is opened with openserverfile, Panorama will not automatically close the database. To close it, use the closeserverfile statement. If there is enough memory on the computer, you can also leave it open for later use. However, in that case you should make sure the Close database after each access option (in the Database Options>Server panel) is not checked, otherwise the database could close if a user opens it for sharing and then closes it. If you want to make sure a database is always open, the best course is to check the Open Automatically when server starts up option, and make sure Close database after each access is not checked.

See Also


10.2UpdatedCarried over from Panorama 6.0, but in Panorama X the database is opened without opening any window.