openserverfile
openserverfile
DATABASE

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

Parameters

This statement has one parameter:

database – name of database to open.

Description

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
    sortup

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

- Auxiliary Databases -- automatically opening multiple databases associated with each other.
- closefile -- closes the current database.
- closeserverfile -- closes the current database (used on the server).
- Custom Database Initialization -- using an .Initialize procedure to automatically run custom code when a database opens.
- Database Integrity Checks -- checking database integrity when opening and saving.
- Database is Damaged Alert -- how to fix the "database is damaged" alert when opening a database.
- getcookie( -- returns the value of a cookie submitted to the server.
- getcookielist( -- returns a list of cookies submitted to the server.
- opendatabase -- opens a database file.
- openfile -- opens a database file. It can also import data from a text file, another database, or a variable into the current database.
- opensavedwindows -- opens windows that were open the last time file was saved.
- opensecret -- opens a database invisibly, without opening its windows.
- opentextfile -- imports data from a text file or a variable into the current database.
- panoramastartupdatabases -- opens any databases specified for startup.
- setcookie -- set the value of a cookie to send back to the client..
- Web Cookies -- web cookies.
- webformitemvalue( -- gets the value of a POST web form item (used when processing a web query with Panorama Server).
- webimagedisplay( -- used within an Image Display Object to specify both a web image (used when the form is displayed in a web browser from Panorama Server) and a local image file (used when the form is displayed within Panorama).
- webshare -- perform record locking operations from a web publishing procedure.

History

Version | Status | Notes
10.2 | Updated | Carried over from Panorama 6.0, but in Panorama X the database is opened without opening any window.