Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.1 » UltraLite - .NET Programming » UltraLite.NET application development

 

Connecting to an UltraLite database

UltraLite applications must connect to a database before carrying out operations on the data in it. This section describes how to connect to an UltraLite database.

Note

The code samples in this chapter are in Microsoft C#. If you are using one of the other supported development tools, you must modify the instructions appropriately.

 Connect to an UltraLite database
  1. Declare a ULConnection object.

    Most applications use a single connection to an UltraLite database and leave the connection open. Multiple connections are only required for multi-threaded data access. For this reason, it is often best to declare the ULConnection object as global to the application.

    ULConnection conn;
  2. Open a connection to an existing database.

    UltraLite applications must deploy an initial database file or the application must include code to create the database file. The initial database file can be created by using Sybase Central or the command line utilities provided with UltraLite.

    You can specify connection parameters either as a connection string or using the ULConnectionParms object. The following example illustrates using the ULConnectionParms object to connect to an UltraLite database namedmydata.udb.

    ULConnectionParms parms = new ULConnectionParms();
    parms.DatabaseOnDesktop = "mydata.udb";
    conn = new ULConnection( parms.ToString() );
    conn.Open();
 Using the ULConnection object
 Multi-threaded applications
 See also