UltraLite for MobileVB User's Guide
Understanding UltraLite for MobileVB Development
Connecting to the UltraLite database
To connect to an UltraLite database
Create a ULDatabaseManager object.
You should create only one ULDatabaseManager object per application. This object is at the root of the object hierarchy. For this reason, it is often best to declare the ULDatabaseManager object global to the application.
The following code creates a ULDatabaseManager object named dbMgr
Public dbMgr As ULDatabaseManager ... Set dbMgr = New ULDatabaseManager
Create and open a connection to the database.
The ULDatabaseManager CreateDatabase and OpenConnection methods are used to Create a database and Open a connection. Each takes a single string as its argument. The string is composed of a set of keyword-value pairs separated by semicolons. A schema file must be specified for CreateDatabase and a database file must be specified for OpenConnection.
The following are mandatory connection parameters for CreateDatabase:
Keyword | Description |
---|---|
schema_file | The path and filename of the UltraLite schema. The default extension for UltraLite schema files is .usm. SCHEMA_FILE is a required parameter when using CreateDatabase on Windows desktop operating systems. CE_SCHEMA has precedence over SCHEMA_FILE. Required for CreateDatabase. |
ce_schema | The path and filename of the UltraLite schema on Windows CE. The default extension for UltraLite schema files is .usm. CE_SCHEMA is a required parameter when using CreateDatabase for CE. |
palm_schema | If using Palm, the name of the UltraLite schema for Palm. PALM_SCHEMA is a required parameter when using CreateDatabase on Palm devices. The Palm file extension is .pdb. Do not specify the extension in the palm_schema parameter. |
For more information on connection parameters, see Connection Parameters.
Most applications use a single connection to an UltraLite database, and keep the connection open all the time. For this reason, it is often best to declare the ULConnection object global to the application.
The following code opens a connection to an UltraLite database named mydata.udb (assuming the file exists).
Public conn As ULConnection Dim conParms as String Dim filePath as String filepath="c:\tutorial" conParms = "uid=dba;pwd=sql;dbf=" + filepath + "\mydata.udb" Set conn = dbMgr.OpenConnection(conParms)