Use the ULDatabaseManager object to create or connect to an UltraLite database named sample.udb.
Prerequisites
There are no prerequisites for this task.
Initialize the ULDatabaseManager object and enable features in UltraLite using the following code:
if( !ULDatabaseManager::Init() ) { return 0; } ULDatabaseManager::EnableAesDBEncryption(); // Use ULDatabaseManager.Fini() when terminating the app. |
Open a connection to an existing database or create a new database if the specified database file does not exist using the following code:
ULConnection * conn; ULError ulerr; conn = ULDatabaseManager::OpenConnection( "dbf=sample.udb;dbkey=aBcD1234", &ulerr ); if( conn == NULL ) { if( ulerr.GetSQLCode() == SQLE_ULTRALITE_DATABASE_NOT_FOUND ) { conn = ULDatabaseManager::CreateDatabase( "dbf=sample.udb;dbkey=aBcD1234", &ulerr ); if( conn == NULL ) { // write code that uses ulerr to determine what happened return 0; } // add code to create the schema for your database } else { // write code that uses ulerr to determine what happened return 0; } } assert( conn != NULL ); |
In this step, you declare a ULError object that contains error information in case the connection is not successful.
![]() |
Discuss this page in DocCommentXchange.
|
Copyright © 2014, SAP AG or an SAP affiliate company. - SAP Sybase SQL Anywhere 16.0 |