UltraLite ActiveX User's Guide
UltraLite ActiveX User's Guide
Guide
No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual,
optical, or otherwise, without the prior written permission of iAnywhere Solutions, Inc. iAnywhere Solutions, Inc. is a subsiduary of
Sybase, Inc.
Sybase, SYBASE (logo), AccelaTrade, ADA Workbench, Adaptable Windowing Environment, Adaptive Component Architecture,
Adaptive Server, Adaptive Server Anywhere, Adaptive Server Enterprise, Adaptive Server Enterprise Monitor, Adaptive Server
Enterprise Replication, Adaptive Server Everywhere, Adaptive Server IQ, Adaptive Warehouse, AnswerBase, Anywhere Studio,
Application Manager, AppModeler, APT Workbench, APT-Build, APT-Edit, APT-Execute, APT-Library, APT-Translator, ASEP,
AvantGo, AvantGo Application Alerts, AvantGo Mobile Delivery, AvantGo Mobile Document Viewer, AvantGo Mobile Inspection,
AvantGo Mobile Marketing Channel, AvantGo Mobile Pharma, AvantGo Mobile Sales, AvantGo Pylon, AvantGo Pylon Application
Server, AvantGo Pylon Conduit, AvantGo Pylon PIM Server, AvantGo Pylon Pro, Backup Server, BayCam, Bit-Wise, BizTracker,
Certified PowerBuilder Developer, Certified SYBASE Professional, Certified SYBASE Professional (logo), ClearConnect, Client
Services, Client-Library, CodeBank, Column Design, ComponentPack, Connection Manager, Convoy/DM, Copernicus, CSP, Data
Pipeline, Data Workbench, DataArchitect, Database Analyzer, DataExpress, DataServer, DataWindow, DB-Library, dbQueue,
Developers Workbench, Direct Connect Anywhere, DirectConnect, Distribution Director, Dynamic Mobility Model, Dynamo, e-ADK,
E-Anywhere, e-Biz Integrator, E-Whatever, EC Gateway, ECMAP, ECRTP, eFulfillment Accelerator, Electronic Case Management,
Embedded SQL, EMS, Enterprise Application Studio, Enterprise Client/Server, Enterprise Connect, Enterprise Data Studio, Enterprise
Manager, Enterprise Portal (logo), Enterprise SQL Server Manager, Enterprise Work Architecture, Enterprise Work Designer,
Enterprise Work Modeler, eProcurement Accelerator, eremote, Everything Works Better When Everything Works Together, EWA,
Financial Fusion, Financial Fusion (and design), Financial Fusion Server, Formula One, Fusion Powered e-Finance, Fusion Powered
Financial Destinations, Fusion Powered STP, Gateway Manager, GeoPoint, GlobalFIX, iAnywhere, iAnywhere Solutions, ImpactNow,
Industry Warehouse Studio, InfoMaker, Information Anywhere, Information Everywhere, InformationConnect, InstaHelp,
InternetBuilder, iremote, iScript, Jaguar CTS, jConnect for JDBC, KnowledgeBase, Logical Memory Manager, M-Business Channel,
M-Business Network, M-Business Server, Mail Anywhere Studio, MainframeConnect, Maintenance Express, Manage Anywhere
Studio, MAP, MDI Access Server, MDI Database Gateway, media.splash, Message Anywhere Server, MetaWorks, MethodSet,
ML Query, MobiCATS, My AvantGo, My AvantGo Media Channel, My AvantGo Mobile Marketing, MySupport, Net-Gateway,
Net-Library, New Era of Networks, Next Generation Learning, Next Generation Learning Studio, O DEVICE, OASiS, OASiS (logo),
ObjectConnect, ObjectCycle, OmniConnect, OmniSQL Access Module, OmniSQL Toolkit, Open Biz, Open Business Interchange,
Open Client, Open Client/Server, Open Client/Server Interfaces, Open ClientConnect, Open Gateway, Open Server, Open
ServerConnect, Open Solutions, Optima++, Partnerships that Work, PB-Gen, PC APT Execute, PC DB-Net, PC Net Library,
PhysicalArchitect, Pocket PowerBuilder, PocketBuilder, Power Through Knowledge, Power++, power.stop, PowerAMC,
PowerBuilder, PowerBuilder Foundation Class Library, PowerDesigner, PowerDimensions, PowerDynamo, Powering the New
Economy, PowerJ, PowerScript, PowerSite, PowerSocket, Powersoft, Powersoft Portfolio, Powersoft Professional, PowerStage,
PowerStudio, PowerTips, PowerWare Desktop, PowerWare Enterprise, ProcessAnalyst, QAnywhere, Rapport, Relational Beans,
RepConnector, Replication Agent, Replication Driver, Replication Server, Replication Server Manager, Replication Toolkit, Report
Workbench, Report-Execute, Resource Manager, RW-DisplayLib, RW-Library, S.W.I.F.T. Message Format Libraries, SAFE,
SAFE/PRO, SDF, Secure SQL Server, Secure SQL Toolset, Security Guardian, SKILS, smart.partners, smart.parts, smart.script,
SQL Advantage, SQL Anywhere, SQL Anywhere Studio, SQL Code Checker, SQL Debug, SQL Edit, SQL Edit/TPU,
SQL Everywhere, SQL Modeler, SQL Remote, SQL Server, SQL Server Manager, SQL Server SNMP SubAgent, SQL Server/CFT,
SQL Server/DBM, SQL SMART, SQL Station, SQL Toolset, SQLJ, Stage III Engineering, Startup.Com, STEP, SupportNow, Sybase
Central, Sybase Client/Server Interfaces, Sybase Development Framework, Sybase Financial Server, Sybase Gateways, Sybase
Learning Connection, Sybase MPP, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase Synergy Program,
Sybase User Workbench, Sybase Virtual Server Architecture, SybaseWare, Syber Financial, SyberAssist, SybMD, SyBooks,
System 10, System 11, System XI (logo), SystemTools, Tabular Data Stream, The Enterprise Client/Server Company, The Extensible
Software Platform, The Future Is Wide Open, The Learning Connection, The Model For Client/Server Solutions, The Online
Information Center, The Power of One, TradeForce, Transact-SQL, Translation Toolkit, Turning Imagination Into Reality, UltraLite,
UltraLite.NET, UNIBOM, Unilib, Uninull, Unisep, Unistring, URK Runtime Kit for UniCode, Versacore, Viewer, VisualWriter, VQL,
Warehouse Control Center, Warehouse Studio, Warehouse WORKS, WarehouseArchitect, Watcom, Watcom SQL, Watcom SQL
Server, Web Deployment Kit, Web.PB, Web.SQL, WebSights, WebViewer, WorkGroup SQL Server, XA-Library, XA-Server, and
XP Server are trademarks of Sybase, Inc. or its subsidiaries.
Certicom and SSL Plus are trademarks and Security Builder is a registered trademark of Certicom Corp. Copyright l’ 1997–2001
Certicom Corp. Portions are Copyright l’ 1997–1998, Consensus Development Corporation, a wholly owned subsidiary of Certicom
Corp. All rights reserved. Contains an implementation of NR signatures, licensed under U.S. patent 5,600,725. Protected by U.S.
patents 5,787,028; 4,745,568; 5,761,305. Patents pending.
ii
Contents
1 Introduction 1
System requirements and supported platforms . . . . . . . . . . . . 2
UltraLite ActiveX architecture . . . . . . . . . . . . . . . . . . . . . . 3
iii
Encryption and obfuscation . . . . . . . . . . . . . . . . . . . . . . . 73
Accessing and manipulating data using Dynamic SQL . . . . . . . . 74
Accessing and manipulating data using the table API . . . . . . . . . 81
Accessing schema information . . . . . . . . . . . . . . . . . . . . . 89
Error handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
User authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Synchronizing UltraLite applications . . . . . . . . . . . . . . . . . . 94
Component samples, demonstrations and code fragments . . . . . . 97
Index 167
iv
About This Manual
Subject This manual describes UltraLite ActiveX. With UltraLite ActiveX you can
develop and deploy database applications to handheld, mobile, or embedded
devices running Windows CE.
Audience This manual is intended for eMbedded Visual Basic and JScript application
developers who want to take advantage of the performance, resource
efficiency, robustness, and security of an UltraLite relational database for
data storage and synchronization.
Familiarity with eMbedded Visual Basic or JScript is assumed.
v
SQL Anywhere Studio documentation
This book is part of the SQL Anywhere documentation set. This section
describes the books in the documentation set and how you can use them.
The SQL Anywhere The SQL Anywhere Studio documentation is available in a variety of forms:
Studio documentation in an online form that combines all books in one large help file; as separate
PDF files for each book; and as printed books that you can purchase. The
documentation consists of the following books:
♦ Introducing SQL Anywhere Studio This book provides an overview of
the SQL Anywhere Studio database management and synchronization
technologies. It includes tutorials to introduce you to each of the pieces
that make up SQL Anywhere Studio.
vi
♦ Adaptive Server Anywhere Error Messages This book provides a
complete listing of Adaptive Server Anywhere error messages together
with diagnostic information.
♦ SQL Anywhere Studio Security Guide This book provides
information about security features in Adaptive Server Anywhere
databases. Adaptive Server Anywhere 7.0 was awarded a TCSEC
(Trusted Computer System Evaluation Criteria) C2 security rating from
the U.S. Government. This book may be of interest to those who wish to
run the current version of Adaptive Server Anywhere in a manner
equivalent to the C2-certified environment.
vii
In addition to this documentation set, PowerDesigner and InfoMaker include
their own online documentation.
Documentation formats SQL Anywhere Studio provides documentation in the following formats:
♦ Online documentation The online documentation contains the
complete SQL Anywhere Studio documentation, including both the
books and the context-sensitive help for SQL Anywhere tools. The online
documentation is updated with each maintenance release of the product,
and is the most complete and up-to-date source of documentation.
To access the online documentation on Windows operating systems,
choose Start ➤ Programs ➤ SQL Anywhere 9 ➤ Online Books. You can
navigate the online documentation using the HTML Help table of
contents, index, and search facility in the left pane, as well as using the
links and menus in the right pane.
To access the online documentation on UNIX operating systems, see the
HTML documentation under your SQL Anywhere installation.
viii
Documentation conventions
This section lists the typographic and graphical conventions used in this
documentation.
Syntax conventions The following conventions are used in the SQL syntax descriptions:
♦ Keywords All SQL keywords appear in upper case, like the words
ALTER TABLE in the following example:
ALTER TABLE [ owner.]table-name
One or more list elements are allowed. In this example, if more than one
is specified, they must be separated by commas.
♦ Optional portions Optional portions of a statement are enclosed by
square brackets.
RELEASE SAVEPOINT [ savepoint-name ]
For example, you can choose one of ASC, DESC, or neither. The square
brackets should not be typed.
♦ Alternatives When precisely one of the options must be chosen, the
alternatives are enclosed in curly braces and a bar is used to separate the
options.
[ QUOTES { ON | OFF } ]
ix
Graphic icons The following icons are used in this documentation.
♦ A client application.
♦ A programming interface.
API
x
The CustDB sample database
Many of the examples in the MobiLink and UltraLite documentation use the
UltraLite sample database.
The reference database for the UltraLite sample database is held in a file
named custdb.db, and is located in the Samples\UltraLite\CustDB
subdirectory of your SQL Anywhere installation. A complete application
built on this database is also supplied in the following subdirectories of your
SQL Anywhere installation:
♦ JScript Samples\UltraLiteActiveX\pie
♦ eMbedded Visual Basic Samples\UltraLiteActiveX\custdb
The sample database is a sales-status database for a hardware supplier. It
holds customer, product, and sales force information for the supplier.
The following figure shows the tables in the CustDB database and how they
are related to each other.
xi
Finding out more and providing feedback
We would like to receive your opinions, suggestions, and feedback on this
documentation.
You can provide feedback on this documentation and on the software
through newsgroups set up to discuss SQL Anywhere technologies. These
newsgroups can be found on the forums.sybase.com news server.
The newsgroups include the following:
♦ sybase.public.sqlanywhere.general.
♦ sybase.public.sqlanywhere.linux.
♦ sybase.public.sqlanywhere.mobilink.
♦ sybase.public.sqlanywhere.product_futures_discussion.
♦ sybase.public.sqlanywhere.replication.
♦ sybase.public.sqlanywhere.ultralite.
Newsgroup disclaimer
iAnywhere Solutions has no obligation to provide solutions, information
or ideas on its newsgroups, nor is iAnywhere Solutions obliged to provide
anything other than a systems operator to monitor the service and insure its
operation and availability.
iAnywhere Solutions Technical Advisors as well as other staff assist on the
newsgroup service when they have time available. They offer their help
on a volunteer basis and may not be available on a regular basis to provide
solutions and information. Their ability to help is based on their workload.
xii
CHAPTER 1
Introduction
About this chapter This chapter introduces you to UltraLite ActiveX and describes its
architecture and functionality.
This chapter also describes the system requirements and supported platforms
for development and deployment.
☞ For more information about creating applications using UltraLite
ActiveX, see “Understanding UltraLite ActiveX Development” on page 59.
☞ For hands-on tutorials introducing UltraLite ActiveX, see the following
chapters:
♦ “Tutorial: An UltraLite Application for PocketPC” on page 5
♦ “Tutorial: Using Dynamic SQL in an UltraLite Application for
PocketPC” on page 25
1
System requirements and supported platforms
Development platforms To develop applications using UltraLite ActiveX, you require the following:
♦ Microsoft Windows NT/2000/XP.
♦ One of the following:
• eMbedded Visual Basic 3.0, for development using Visual Basic
• Pocket Internet Explorer, for development using JScript
☞ For more information, see “UltraLite host platforms” [Introducing SQL
Anywhere Studio, page 126].
2
Chapter 1. Introduction
ULConnection ULDatabaseSchema
ULSyncResult IULPublicationSchemas
ULTable ULPublicationSchema
ULTableSchema
IULIndexSchemas
IULColumns ULIndexSchema
ULColumn
ULSyncParms ULColumnSchema
ULPreparedStatement ULResultSet
3
☞ For more information about ULConnection, see “ULConnection
class” on page 111.
4
CHAPTER 2
About this chapter This chapter provides a tutorial to guide you through the process of building
an UltraLite ActiveX application using eMbedded Visual Basic.
☞ For a sample UltraLite ActiveX application using JScript, see “Tutorial:
An UltraLite Application for Pocket IE” on page 43.
Contents Topic: page
Introduction 6
Summary 23
5
Introduction
This tutorial guides you through the process of building an UltraLite
ActiveX application using the table API. At the end of the tutorial you will
have an application and small database on your Windows CE device that
synchronizes with a central database.
Timing The tutorial takes about 30 minutes if you copy and paste the code. If you
enter the code yourself, it takes significantly longer.
Competencies and This tutorial assumes:
experience
♦ you have Microsoft eMbedded Visual Tools installed on your computer
♦ you know how to create an UltraLite schema using the UltraLite Schema
Painter.
Note
You can perform most of this tutorial without SQL Anywhere Studio. The
synchronization sections of the tutorial require SQL Anywhere Studio.
The synchronization section of this tutorial requires that you can use
command line options and parameters.
Goals The goals for the tutorial are to gain competence and familiarity with the
process of developing an UltraLite application.
6
Chapter 2. Tutorial: An UltraLite Application for PocketPC
id integer No autoincrement
7
❖ To create a reference to UltraLite ActiveX
1. Start eMbedded Visual Basic.
Choose Start ➤ Programs ➤ Microsoft eMbedded Visual Tools ➤
eMbedded Visual Basic 3.0.
The New Project window appears.
2. Choose a target and click OK.
The remainder of the tutorial assumes that you have chosen Windows CE
for the Pocket PC project.
8
Chapter 2. Tutorial: An UltraLite Application for PocketPC
TextBox txtfname
TextBox txtlname
TextBox txtcity
TextBox txtphone
Label lblID
Button btnInsert Insert
9
Configure the emulator to support UltraLite ActiveX
Once you add UltraLite objects to your application, you must add the
UltraLite ActiveX control to the emulator in order to debug and test your
application.
10
Chapter 2. Tutorial: An UltraLite Application for PocketPC
11
Lesson 3: Write the sample code
This lesson guides you through the process of writing eMbedded Visual
Basic code to connect to a database, navigate within the database, and
manipulate the data in the database.
This lesson includes instructions for synchronizing your application with an
Adaptive Server Anywhere database. This portion of the lesson is optional,
and requires SQL Anywhere Studio.
12
Chapter 2. Tutorial: An UltraLite Application for PocketPC
Sub Form_Load()
Dim conn_parms As String
Dim open_parms As String
Dim schema_parms As String
On Error Resume Next
conn_parms = "uid=DBA;pwd=SQL"
open_parms = conn_parms & ";ce_file=\Program Files\
tutorial\tutCustomer.udb"
schema_parms = open_parms & ";ce_schema=\Program Files\
tutorial\tutCustomer.usm"
Set DatabaseMgr =
CreateObject("UltraLite.ULDatabaseManager")
Set Connection = DatabaseMgr.OpenConnection(open_parms)
If Err.Number = UlSQLCode.ulSQLE_NOERROR Then
MsgBox "Connected to an existing database."
ElseIf Err.Number = UlSQLCode.ulSQLE_DATABASE_NOT_FOUND
Then
Err.Clear
Set Connection = DatabaseMgr.CreateDatabase(schema_
parms)
If Err.Number <> 0 Then
MsgBox Err.Description
Else
MsgBox "Connected to a new database"
End If
End If
End Sub
13
Set CustomerTable = Connection.GetTable("customer")
CustomerTable.Open
At this stage you may want to run the application to check that you have
entered the code correctly. As there are no rows in the table, the controls
are all empty.
14
Chapter 2. Tutorial: An UltraLite Application for PocketPC
The call to InsertBegin puts the application into insert mode and sets all
the values in the row to their defaults. For example, the ID column
receives the next autoincrement value. The column values are set and
then the new row is inserted.
2. Run the application.
After an initial message box, the form is displayed.
3. Insert two rows into the database.
♦ Enter a first name of Jane in the first text box and a last name of Doe in
the second. Click Insert.
A row is added to the table with these values. The application moves to
the last row of the table and displays the row. The label displays the
automatically incremented value of the ID column that UltraLite
assigned to the row.
♦ Enter a first name of John in the first text box and a last name of Smith
in the second. Click Insert.
15
❖ To move through the rows of the table
1. Write code to implement the Next and Previous buttons.
Add the following procedures to the form:
Private Sub btnNext_Click()
If Not CustomerTable.MoveNext Then
CustomerTable.MoveLast
End If
DisplayCurrentRow
End Sub
Private Sub btnPrevious_Click()
If Not CustomerTable.MovePrevious Then
CustomerTable.MoveFirst
End If
DisplayCurrentRow
End Sub
16
Chapter 2. Tutorial: An UltraLite Application for PocketPC
fname = txtFname.Text
lname = txtLname.Text
city = txtCity.Text
phone = txtPhone.Text
CustomerTable.UpdateBegin
CustomerTable.Columns("Fname").Value = _
fname
CustomerTable.Columns("Lname").Value = _
lname
If Len(city) > 0 Then
CustomerTable.Columns("City").Value = _
city
End If
If Len(phone) > 0 Then
CustomerTable.Columns("Phone").Value = _
phone
End If
CustomerTable.Update
DisplayCurrentRow
Exit Sub
End Sub
Note
You can now run this application as a standalone application without
SQL Anywhere Studio. To synchronize your UltraLite database with an
Adaptive Server Anywhere database, you can complete the remainder of
this lesson.
17
Write code to synchronize
The following procedure implements synchronization. Synchronization
requires SQL Anywhere Studio.
The -zu+ and -za command line options provide automatic addition of
users and generation of synchronization scripts. For more information
18
Chapter 2. Tutorial: An UltraLite Application for PocketPC
19
Lesson 4: Deploy to a device
You can deploy your application to a device manually, or using the
Application Install Wizard. The following sections describe both procedures.
20
Chapter 2. Tutorial: An UltraLite Application for PocketPC
21
8. Select the processors your application will support. If you select more
than one processor, each will be contained in a separate .cab file. Click
Next.
9. Select iAnywhere Solutions, ActiveX for UltraLite. The UltraLite
ActiveX control will be registered automatically upon installation of your
application. Click Next.
10. Deploy the schema file to your device.
♦ Click Add.
♦ Browse to c:\tutorial\tutcustomer.usm.
♦ Click Open.
♦ If a prompt asks whether it is a system file, click No.
♦ Check Include Device Runtimes in Cab file if you want the device
runtimes to be included in your installation. The device runtimes are
not always required and can make the .cab file very large if included.
If the application works with the currently installed runtimes, there is
no need to check this option.
♦ Click Next.
11. Enter tutorial in each of the fields. Click Next.
12. Click Create Install to create the .cab files and setup executable.
The wizard creates a folder, CD1, in the directory you specified to store
the output files. CD1 contains all the files you need to distribute your
application.
22
Chapter 2. Tutorial: An UltraLite Application for PocketPC
Summary
Learning During this tutorial, you:
accomplishments
♦ created a database schema
♦ created an UltraLite application
23
CHAPTER 3
About this chapter This chapter provides a tutorial to guide you through the process of building
an UltraLite ActiveX application. This tutorial differs from “Tutorial: An
UltraLite Application for PocketPC” on page 5 in that you use dynamic SQL
to access the UltraLite database.
☞ For a sample UltraLite ActiveX application using JScript, see “Tutorial:
An UltraLite Application for Pocket IE” on page 43.
Contents Topic: page
Introduction 26
Summary 41
25
Introduction
This tutorial guides you through the process of building an UltraLite
ActiveX application using dynamic SQL for data access. At the end of the
tutorial you will have an application and a small database on your Windows
CE device that synchronizes with a central database.
Timing The tutorial takes about 30 minutes if you copy and paste the code. If you
enter the code yourself, it takes significantly longer.
Competencies and This tutorial assumes:
experience
♦ you have Microsoft eMbedded Visual Tools installed on your computer
♦ you know how to create an UltraLite schema using the UltraLite Schema
Painter.
Note
You can perform most of this tutorial without SQL Anywhere Studio. The
synchronization sections of the tutorial require SQL Anywhere Studio.
Goals The goals for the tutorial are to gain competence and familiarity with the
process of developing an UltraLite application using dynamic SQL.
26
Chapter 3. Tutorial: Using Dynamic SQL in an UltraLite Application for PocketPC
id integer No autoincrement
27
2. Choose a target and click OK.
The remainder of the tutorial assumes that you have chosen Windows CE
for the Pocket PC project.
3. Create a reference to UltraLite ActiveX.
♦ Click Project ➤ References.
♦ If this is the first time you have run eMbedded Visual Basic with
UltraLite, add the control to the list of available references.
• Browse to the ultralite\UltraLiteActiveX\win32\ subdirectory of
your SQL Anywhere installation.
• Select uldo9.dll and click OK.
iAnywhere Solutions, ActiveX for UltraLite is added to the list of
available references.
♦ Select iAnywhere Solutions, ActiveX for UltraLite and click OK to
add the control to your project.
Your eMbedded Visual Basic environment is now capable of
supporting UltraLite ActiveX.
28
Chapter 3. Tutorial: Using Dynamic SQL in an UltraLite Application for PocketPC
TextBox txtName
Label lblID
29
❖ To add the UltraLite ActiveX control to the emulator
1. Start the Control Manager.
In eMbedded Visual Basic, select Tools ➤ Remote Tools ➤ Control
Manager.
2. Select the target emulator.
In the left pane, open Pocket PC and select Pocket PC Emulation.
3. Add the UltraLite control.
♦ Click Control ➤ Add New Control.
Browse to ultralite\UltraLiteActiveX\ce\emulator30\uldo9.dll, located
in SQL Anywhere directory.
♦ Click OK
Note that uldo9.dll is an ActiveX file, not a control, so it will not
appear in the list of controls on the device.
30
Chapter 3. Tutorial: Using Dynamic SQL in an UltraLite Application for PocketPC
31
Sub Form_Load()
’ Use CreateObject to get an instance of the Database
Manager object
Set DatabaseMgr =
CreateObject("UltraLite.ULDatabaseManager")
’ Create a LoginParms object, using CreateObject
Dim LoginParms As ULConnectionParms
Set LoginParms =
CreateObject("UltraLite.ULConnectionParms")
LoginParms.DatabaseOnCE = "\Program Files\tutorial\
tutorial.udb"
LoginParms.SchemaOnCE = "\Program Files\tutorial\
tutorial.usm"
LoginParms.CacheSize = "128k"
On Error Resume Next
’ Use the "WithParms" calls
Set Connection = _
DatabaseMgr.OpenConnectionWithParms(LoginParms)
If Err.Number = ULSQLCode.ulSQLE_NOERROR Then
MsgBox "Connected to an existing database"
ElseIf Err.Number = _
ULSQLCode.ulSQLE_ULTRALITE_DATABASE_NOT_FOUND Then
Err.Clear
Set Connection = _
DatabaseMgr.CreateDatabaseWithParms(LoginParms)
If Err.Number = ULSQLCode.ulSQLE_NOERROR Then
MsgBox "Connected to a new database"
Else
MsgBox Err.Description
End If
End If
Set MyPrepStmt = _
Connection.PrepareStatement("SELECT id, name FROM
names")
Set MyResultSet = MyPrepStmt.ExecuteQuery
MyResultSet.MoveFirst
End Sub
4. Write the code that ends the application and closes the connection when
the End button is clicked.
Sub btnDone_Click()
Connection.Close
End Sub
32
Chapter 3. Tutorial: Using Dynamic SQL in an UltraLite Application for PocketPC
At this stage you may want to run the application to check that you have
entered the code correctly. As there are no rows in the table, the controls
are all empty.
33
❖ To insert rows into the table
1. Write code to implement the Insert button.
Add the following procedure to the form:
Private Sub btnInsert_Click()
Dim PrepStmt As ULPreparedStatement
If txtName.Text <> "" Then
Set PrepStmt = Connection.PrepareStatement("INSERT INTO
names(name) values(?)")
PrepStmt.SetParameter 1, txtName.Text
PrepStmt.ExecuteStatement
MyResultSet.MoveRelative(0)
MyResultSet.MoveLast
DisplayCurrentRow
Else
MsgBox "Enter a name to insert in the database"
End If
End Sub
34
Chapter 3. Tutorial: Using Dynamic SQL in an UltraLite Application for PocketPC
Note
You can now run this application as a standalone application without
SQL Anywhere Studio. To synchronize your UltraLite database with an
Adaptive Server Anywhere database, you can complete the remainder of
this lesson.
35
Write code to synchronize
The following procedure implements synchronization. Synchronization
requires SQL Anywhere Studio.
❖ To implement synchronization
1. Add a button to your form named btnSync with the caption Synchronize.
2. Write code to implement the Synchronize button.
In the code below, the SyncParms object contains the synchronization
parameters. Setting its SendColumnNames property to true sends the
column names to MobiLink so that it can generate upload and download
scripts.
Add the following procedure to the form:
Private Sub btnSync_Click()
Dim parms As ULSyncParms
Dim result As ULSyncResult
On Error Resume Next
Set parms = Connection.SyncParms
Set result = Connection.SyncResult
parms.UserName = "ULevbUser"
parms.Stream = ULStreamType.ulTCPIP
parms.Version = "ul_default"
parms.SendColumnNames = True
Connection.Synchronize (False)
If Err.Number <> UlSQLCode.ulSQLE_NOERROR Then
MsgBox result.StreamErrorCode
End If
End Sub
36
Chapter 3. Tutorial: Using Dynamic SQL in an UltraLite Application for PocketPC
The -zu+ and -za command line options provide automatic addition of
users and generation of synchronization scripts. For more information
about these options, see “MobiLink Synchronization Server Options”
[MobiLink Synchronization Reference, page 3].
37
Lesson 4: Deploy to a device
You can deploy your application to a device manually, or using the
Application Install Wizard. The following sections describe both procedures.
38
Chapter 3. Tutorial: Using Dynamic SQL in an UltraLite Application for PocketPC
39
7. Browse to c:\tutorial\evb\. Click Next.
8. Select the processors your application will support. If you select more
than one processor, each will be contained in a separate .cab file. Click
Next.
9. Select iAnywhere Solutions, ActiveX for UltraLite. The UltraLite
ActiveX control will be registered automatically upon installation of your
application. Click Next.
10. Deploy the schema file to your device.
♦ Click Add.
♦ Browse to c:\tutorial\tutorial.usm.
♦ Click Open.
♦ If a prompt asks whether it is a system file, click No.
♦ Check Include Device Runtimes in Cab file if you want the device
runtimes to be included in your installation. The device runtimes are
not always required and can make the .cab file very large if included.
If the application works with the currently installed runtimes, there is
no need to check this option.
♦ Click Next.
11. Enter tutorial in each of the fields. Click Next.
12. Click Create Install to create the .cab files and setup executable.
The wizard creates a folder, CD1, in the directory you specified to store
the output files. CD1 contains all the files you need to distribute your
application.
40
Chapter 3. Tutorial: Using Dynamic SQL in an UltraLite Application for PocketPC
Summary
Learning During this tutorial, you:
accomplishments
♦ created a database schema
♦ created an UltraLite ActiveX application
41
CHAPTER 4
About this chapter This chapter provides a tutorial to guide you through the process of building
an UltraLite ActiveX application for Pocket Internet Explorer. The
application accesses the UltraLite ActiveX package using JScript embedded
on an HTML page.
☞ For a sample UltraLite ActiveX application using eMbedded Visual
Basic, see “Tutorial: An UltraLite Application for PocketPC” on page 5 or
“Tutorial: Using Dynamic SQL in an UltraLite Application for PocketPC”
on page 25.
Contents Topic: page
Introduction 44
43
Introduction
This tutorial guides you through the process of building an UltraLite
ActiveX application. At the end of the tutorial you will have an application
and small database on your Windows CE device that synchronizes with a
database running on your desktop computer.
This tutorial describes the CustDB sample application. This application
demonstrates the capabilities of UltraLite ActiveX used from Pocket Internet
Explorer (Pocket IE). It runs on a Windows CE device.
The CustDB sample is fully-functional customer application. The CustDB
sample application provides you with examples of how to implement many
of the techniques you will need to develop UltraLite ActiveX applications.
The CustDB sample application is written in JScript and HTML. The code
for this application is located in the Samples\UltraLiteActiveX\pie
subdirectory of your SQL Anywhere 9 installation.
Note
This application uses frames and so will only work on versions of Pocket
IE later than 1.1.
Timing The tutorial takes about 50 minutes.
Competencies and This tutorial assumes:
experience
♦ you are familiar with JScript and Pocket Internet Explorer
• you can write, test, and troubleshoot a JScript application
44
Chapter 4. Tutorial: An UltraLite Application for Pocket IE
45
Lesson 2: Deploy to a device
The following procedure copies the HTML files containing embedded
JScript to your remote device. Alternatively, you can access the files
remotely from your hard drive or server using a web server and an internet
connection.
2. In the left pane, open the folder corresponding to your device type. Select
your device.
The File Viewer connects to your device.
3. Choose File ➤ New Folder. Create a folder named pie in the root of your
device.
46
Chapter 4. Tutorial: An UltraLite Application for Pocket IE
47
2. The File Viewer connects to your device.
♦ Choose Connection ➤ Add New Connection.
♦ Open the folder corresponding to your device type.
♦ Select your device.
48
Chapter 4. Tutorial: An UltraLite Application for Pocket IE
These lines create the text boxes given in the table below.
49
INPUT TYPE NAME VALUE OnClick
50
Chapter 4. Tutorial: An UltraLite Application for Pocket IE
51
❖ To connect to the UltraLite database
1. Start Pocket Internet Explorer.
2. Open login.htm.
4. A script prompts you to enter an employee ID. Accept the default value
of 50.
52
Chapter 4. Tutorial: An UltraLite Application for Pocket IE
53
function OpenGetOrder() {
var conn = top.Connection;
var cs = top.CS;
var empid;
if ( conn == null ) {
alert("Not yet connected!");
return;
}
conn.AutoCommit = false;
var table = conn.GetTable("ULIdentifyEmployee_nosync");
table.Open();
if ( table.RowCount == 0 ) {
empid = window.prompt("Enter employee ID #: ", "50");
table.InsertBegin();
table.Columns("emp_id").value = empid;
table.Insert();
conn.Commit();
}
table.MoveFirst();
cs.SetEmployeeID( table.Columns("emp_id").value );
table.Close();
ProductList = conn.GetTable("ULProduct");
ProductList.Open();
CustomerList = conn.GetTable("ULCustomer");
CustomerList.Open();
OrderList = conn.GetTable("ULOrder");
OrderList.Open();
SetOrderData();
SkipToValidOrder();
}
54
Chapter 4. Tutorial: An UltraLite Application for Pocket IE
function UpdateForm() {
var cs = top.CS;
if ( cs.GetNoOrder() ) {
txt_Custname.value = "";
txt_Prodname.value = "";
txt_Quant.value = "";
txt_Price.value = "";
txt_Discount.value = "";
txt_Status.value = "";
txt_Notes.value = "";
return;
}
txt_Custname.value = cs.GetCustName();
txt_Prodname.value = cs.GetProdName();
txt_Quant.value = cs.GetQuantity();
txt_Price.value = cs.GetPrice();
txt_Discount.value = cs.GetDiscount();
txt_Status.value = cs.GetStatus();
txt_Notes.value = cs.GetNotes();
if ( cs.FirstOrder() == cs.GetOrderID() ) {
SetStatus("First Order");
} else if ( cs.LastOrder() == cs.GetOrderID() ) {
SetStatus("Last Order");
}
}
55
❖ To add an order to the database
1. Tap Add.
The following script runs, replacing main.htm with add.htm in the frame.
function addNewOrder() {
document.location.replace("add.htm");
}
56
Chapter 4. Tutorial: An UltraLite Application for Pocket IE
function ApproveOrder() {
var cs = top.CS;
document.location.replace("approve.htm");
}
function DenyOrder() {
document.location.replace("deny.htm");
}
57
CHAPTER 5
About this chapter This chapter explains how to develop applications using UltraLite ActiveX.
☞ For hands-on tutorials using UltraLite ActiveX, see the following
chapters:
♦ “Tutorial: An UltraLite Application for PocketPC” on page 5
♦ “Tutorial: Using Dynamic SQL in an UltraLite Application for
PocketPC” on page 25
Error handling 90
User authentication 93
59
Preparing to work with UltraLite ActiveX
There are several steps you must take before you can build an application
using UltraLite ActiveX.
60
Chapter 5. Understanding UltraLite ActiveX Development
2. If your device does not appear in the left pane, connect to the device:
♦ Choose Connection ➤ Add Connection.
♦ Select your device from the list and click OK to establish a connection.
3. Copy the schema file to the device
♦ Select a destination directory on the device.
♦ Choose File ➤ Export File.
♦ Locate the schema (.usm ) file.
♦ Click OK to export the file to the device.
61
Cached pages
To prevent Pocket IE from using locally cached pages and to ensure all
contact is dynamically recalculated, the page expiry should be set to 0. This
will cause Pocket IE to always reload the page. Use the following as the first
line of your HTML document.
<META HTTP-EQUIV="Expires" CONTENT="0">
To force scripts to run before the page is loaded, for example, to get a
database connection which results in dynamic HTML content, place those
scripts in the HTML head:
<head> <script>... </script></head>
Pocket IE limitations
The JScript language supported by Pocket IE is incompatible with that of
Internet Explorer 4 and up, in the following ways:
♦ Pocket IE JScript is case insensitive. Scripts written for Pocket IE may
not work on IE unless the proper case is used.
♦ The BUTTON tag is not supported, but a button can be created using
<INPUT TYPE=“BUTTON”>.
♦ HTML tag names are in the same namespace as JScript functions. Ensure
that the name of an HTML element does not conflict with any function
names in the current document.
For example, pressing this button will cause an error:
<SCRIPT>
function b_Done() { ... }
</SCRIPT>
<INPUT NAME="b_Done" TYPE="BUTTON" VALUE="Done" onClick="b_
Done()">
62
Chapter 5. Understanding UltraLite ActiveX Development
63
A schema file is also used in the initial creation of a database to specify the
structure of the database.
♦ The ulinit utility If you have the Adaptive Server Anywhere database
management system, you can generate an UltraLite schema file using the
ulinit command line utility.
You apply the schema file to the database from the UltraLite application,
either when you create a new database or using the ApplyFile method.
☞ For more information about creating a new database, see “Connecting to
an UltraLite database” on page 66.
64
Chapter 5. Understanding UltraLite ActiveX Development
// JScript
var db;
var conn;
db = new ActiveXObject("UltraLite.ULDatabaseManager");
conn = db.OpenConnection("dbf = \\My Documents\\mydb.udb");
if ( conn.Schema.TableCount == 0 ) {
conn.Schema.ApplyFile("\\My Documents\\myschema.usm");
}
65
Connecting to an UltraLite database
Your UltraLite application must connect to a database before it can carry out
operations on the data in the database.
Using the ULConnection The following properties of the ULConnection object govern global
object application behavior.
☞ For more information about the ULConnection object, see
“ULConnection class” on page 111.
♦ Commit behavior By default, UltraLite applications are in
AutoCommit mode. Each insert, update, or delete statement is committed
to the database immediately. Set ULConnection.AutoCommit to false to
build transactions into your application. Turning AutoCommit off and
performing commits directly can improve the performance of your
application.
☞ For more information, see “Commit method” on page 113.
♦ User authentication You can change the user ID and password for the
application from the default values of DBA and SQL by using the
GrantConnectTo and RevokeConnectFrom methods.
☞ For more information, see “User authentication” on page 93.
♦ Synchronization A set of objects governing synchronization are
accessed from the ULConnection object.
☞ For more information, see “Synchronizing UltraLite applications” on
page 94.
66
Chapter 5. Understanding UltraLite ActiveX Development
67
Using the following properties, you must specify a schema file for
CreateDatabaseWithParms or a database file for
OpenConnectionWithParms. For information about additional properties,
see “Properties” on page 117.
Keyword Description
68
Chapter 5. Understanding UltraLite ActiveX Development
// JScript
DatabaseMgr.ErrorResume = true;
Connection =
DatabaseMgr.OpenConnectionWithParms(LoginParms);
if ( DatabaseMgr.LastErrorCode != 0 ) {
Connection =
DatabaseMgr.CreateDatabaseWithParms(LoginParms);
}
69
connection as a ULConnection object. Each method takes a single
string string as its argument. The string is composed of a set of
keyword=value pairs.
The following code generates a connection string that specifies the
required parameters.
☞ For more information about connection parameters, see
“Connection Parameters” [UltraLite Database User’s Guide, page 49].
’ eMbedded Visual Basic
Dim open_parms, schema_parms As String
open_parms = "ce_file=\tutorial.udb"
schema_parms = open_parms & ";" & "ce_schema=\
tutorial.usm"
// JScript
var open_parms, schema_parms;
open_parms = ";file_name=\\UltraLiteDB\\ul_custapi.udb";
schema_parms = open_parms + ";schema_file=\\UltraLiteDB\
\ul_custdb.usm";
70
Chapter 5. Understanding UltraLite ActiveX Development
Note
Support for frames is not included in versions of Pocket IE prior to 1.1.
The following code fragment defines two frames.
// JScript
<frameset rows="5%,*" BORDER=0>
<frame SRC="topline.htm" NAME="TopLine" MARGINWIDTH=0
MARGINHEIGHT=0>
<frame SRC="connect.htm" NAME="Connect" MARGINWIDTH=0
MARGINHEIGHT=0>
</frameset>
<SCRIPT LANGUAGE="JScript">
var Connection; // UltraLite Connection
var DatabaseMgr; // UltraLite Database Manager
</SCRIPT>
71
The following code fragment creates a new variable, conn, and assigns the
connection created in the top frame to it. If you are in top, referencing the
connection as top.Connection is optional.
// JScript
<SCRIPT>
function usingConnection() {
if ( top.Connection == null ) {
return; // not yet connected..
}
var conn = top.Connection;
...
}
</SCRIPT>
To swap forms in and out of the frameset, a JScript function can use the
document.location.replace method. The following code fragment closes
the current connection and returns to the connect form.
// JScript
<SCRIPT>
function exitApp() {
if ( top.Connection != null ) {
top.Connection.Close();
}
document.location.replace("connect.htm");
}
</SCRIPT>
<INPUT NAME="b_Done" TYPE="BUTTON" VALUE="Done"
onClick="exitApp()">
72
Chapter 5. Understanding UltraLite ActiveX Development
After the database is encrypted, connections to the database must specify the
correct encryption key. Otherwise, the connection fails.
To obfuscate the database, specify obfuscate=1 as a creation parameter.
☞ For more information about database encryption, see “Encrypting
UltraLite databases” [UltraLite Database User’s Guide, page 36].
73
Accessing and manipulating data using Dynamic
SQL
UltraLite applications can access data in an Ultralite database using
Dynamic SQL or the table API.
☞ For information about the table API, see “Accessing and manipulating
data using the table API” on page 81.
The following section explains how to perform the following tasks using
Dynamic SQL.
♦ Scrolling through the rows of a table.
♦ Accessing the values of the current row.
♦ Locating rows in a table.
♦ Inserting, deleting, and updating rows.
❖ To INSERT a row
1. Declare a ULPreparedStatement object.
’ eMbedded Visual Basic
Dim PS As ULPreparedStatement
// JScript
var PS;
74
Chapter 5. Understanding UltraLite ActiveX Development
❖ To UPDATE a row
1. Declare a ULPreparedStatement object.
’ eMbedded Visual Basic
Dim PS As ULPreparedStatement
// JScript
var PS;
75
// JScript
var NewValue;
NewValue = "Bob";
PS.SetParameter(1, NewValue);
PS.SetParameter(2, "6");
❖ To DELETE a row
1. Declare a ULPreparedStatement object.
’ eMbedded Visual Basic
Dim PS As ULPreparedStatement
// JScript
var PS;
76
Chapter 5. Understanding UltraLite ActiveX Development
The code fragment below demonstrates how to use the Value property to
obtain the column values for the current row. The Value property uses the
following syntax: MyResultSetName.Value(Index) where Index is the
ordinal position of the column name in your SELECT statement.
This example uses the Value property access both Integer and String values.
UltraLite ActiveX uses a variant data type to achieve this flexibility.
’ eMbedded Visual Basic
If MyResultSet.RowCount = 0 Then
lblID.Text = ""
txtName.Text = ""
Else
lblID.Caption = MyResultSet.Value(1)
txtName.Text = MyResultSet.Value(2)
End If
77
// JScript
If ( MyResultSet.RowCount == 0 ) {
lblID.Text = "";
txtName.Text = "";
} Else {
lblID.Caption = MyResultSet.Value(1);
lblID.Text = MyResultSet.Value(2);
}
In the JScript code below, an string captures the result of the SELECT
query as an HTML table.
78
Chapter 5. Understanding UltraLite ActiveX Development
// JScript
var y;
var resultTable;
y = PS.ExecuteQuery();
var ncols = y.Schema.ColumnCount;
var fld, line, nrows;
resultTable = "<html><table cellpadding=0
cellspacing=0><tr>";
resultTable = resultTable + "<th>" + "ColumnName" + "</th>";
resultTable = resultTable + "</tr><tr>";
nrows = 0;
while ( y.MoveNext() ) {
line = "<tr>";
nrows++;
if ( y.IsNull(1) ) {
fld = "(null)";
} else {
fld = y.Value(1);
}
line = line + "<td>" + fld + "</td>";
resultTable = resultTable + line + "</tr>";
}
resultTable = resultTable + "</table><B>#Rows=" + nrows +
"</B></html>";
79
values move backward in the result set, and zero does not move the
cursor. Zero is useful if you want to repopulate a row buffer.
The same technique is used for all of the Move methods. For more
information about these navigational methods, see “ULResultSet class” on
page 136.
80
Chapter 5. Understanding UltraLite ActiveX Development
81
’ eMbedded Visual Basic
Set colLastName = tCustomer.Columns.(LastName)
// JScript
colLastName = tCustomer.Columns.(LastName);
You expose the rows of the table to the application when you open the table
object. By default, the rows are exposed in order by primary key value, but
you can specify an index to access the rows in a particular order. The
following code moves to the first row of the customer table as ordered by the
ix_name index.
’ eMbedded Visual Basic
Set tCustomer = Connection.GetTable("customer")
tCustomer.Open "ix_name"
tCustomer.MoveFirst
// JScript
tCustomer = Connection.GetTable("customer");
tCustomer.Open("ix_name");
tCustomer.MoveFirst();
82
Chapter 5. Understanding UltraLite ActiveX Development
You can also use the Value property to set values. For example:
’ eMbedded Visual Basic
colLastName.Value = "Kaminski"
// JScript
colLastName.Value = "Kaminski";
By assigning values to these properties you do not alter the value of the data
in the database. You can assign values to the properties even if you are
before the first row or after the last row of the table, but it is an error to try to
access data when the current row is in one of these positions. For example,
the following code fragment generates an error.
’ This eMbedded Viusal Basic code is incorrect
tCustomer.MoveBeforeFirst
id = colID.Value
Casting values As the Value method returns a variant, you can use it to access columns of
any data type.
Note
The columns searched using Find and Lookup methods must be in the
index used to open the table.
♦ Find methods move to the first row that exactly matches a specified
search value, under the sort order specified when the ULTable object was
opened.
☞ For more information about find methods, see “FindBegin method”
on page 158.
♦ Lookup methods move to the first row that matches or is greater than a
specified search value, under the sort order specified when the ULTable
object was opened.
☞ For more information about lookup methods, see “LookupBackward
method” on page 161.
83
❖ To search for a row
1. Enter find or lookup mode.
Call the FindBegin or LookupBegin method. For example, the following
code fragment calls ULTable.FindBegin.
’ eMbedded Visual Basic
tCustomer.FindBegin
// JScript
tCustomer.FindBegin();
For multi-column indexes, a value for the first column is required, but
you can omit the other columns.
84
Chapter 5. Understanding UltraLite ActiveX Development
// JScript
colID.Value = 3;
Using UltraLite modes UltraLite uses the values in the buffer for a different purpose, depending on
the kind of operation you are carrying out. UltraLite has four different
modes of operation, in addition to the default mode.
♦ Insert mode The data in the buffer is added to the table as a new row
when the ULTable.Insert method is called.
♦ Update mode The data in the buffer replaces the current row when the
ULTable.Update method is called.
♦ Find mode The data in the buffer is used to locate rows when one of the
ULTable.Find methods is called.
♦ Lookup mode The data in the buffer is used to locate rows when one of
the ULTable.Lookup methods is called.
❖ To update a row
1. Move to the row you wish to update.
You can move to a row by scrolling through the table or by searching
using Find and Lookup methods.
2. Enter Update mode.
For example, the following instruction enters Update mode on the table
tCustomer.
’ eMbedded Visual Basic
tCustomer.UpdateBegin
// JScript
tCustomer.UpdateBegin();
85
After the update operation, the current row is the row that was just updated.
If you changed the value of a column in the index specified when the
ULTable object was opened, there are some subtleties to the positioning.
By default, UltraLite operates in AutoCommit mode, so that the update is
immediately applied to the row in permanent storage. If you have disabled
AutoCommit mode, the update is not applied until you execute a commit
operation. For more information, see “Transaction processing in UltraLite”
on page 88.
Caution
Do not update the primary key of a row: delete the row and add a new row
instead.
Inserting rows The steps to insert a row are very similar to those for updating rows, except
that there is no need to locate any particular row in the table before carrying
out the insert operation. Rows are automatically sorted by the index
specified when opening the table.
❖ To insert a row
1. Enter Insert mode.
For example, the following instruction enters Insert mode on the table
CustomerTable.
’ eMbedded Visual Basic
CustomerTable.InsertBegin
// JScript
CustomerTable.InsertBegin();
86
Chapter 5. Understanding UltraLite ActiveX Development
Deleting rows There is no delete mode corresponding to the insert or update modes.
The following procedure deletes a row.
❖ To delete a row
1. Move to the row you wish to delete.
2. Execute the deletion.
’eMbedded Visual Basic
tCustomer.Delete
// JScript
tCustomer.Delete();
87
Transaction processing in UltraLite
UltraLite provides transaction processing to ensure the integrity of the data
in your database. A transaction is a logical unit of work: either the entire
transaction is executed, or none of it is executed.
By default, UltraLite operates in AutoCommit mode. In AutoCommit mode,
each insert, update, or delete is executed as a separate transaction. Once the
operation is completed, the change is made to the database.
If you set the ULConnection.AutoCommit property to false, you can use
multi-statement transactions. For example, if your application transfers
money between two accounts, the deduction from the source account and the
addition to the destination account constitute a single transaction.
If AutoCommit is set to false, you must execute a ULConnection.Commit
statement to complete a transaction and make changes to your database
permanent, or you must execute a ULConnection. Rollback statement to
cancel all the operations of a transaction.
Note
Synchronization causes an AutoCommit even if you have AutoCommit set
to False.
Turning AutoCommit off improves performance.
88
Chapter 5. Understanding UltraLite ActiveX Development
Note
You cannot modify the schema through the API. You can only retrieve
information about the schema.
☞ For information about modifying the schema, see “Creating UltraLite
database schema files” on page 64.
♦ ULDatabaseSchema The number and names of the tables in the
database, as well as global properties such as the format of dates and
times.
To obtain a ULDatabaseSchema object, access the
ULConnection.Schema property.
♦ ULTableSchema The number and names of columns in the table, as
well as the Indexes collections for the table.
To obtain a ULTableSchema object, access the ULTable.Schema property.
89
Error handling
In normal operation, UltraLite ActiveX can throw errors that are intended to
be caught and handled in the script environment. Errors are expressed as
SQLCODE values, negative numbers indicating the particular kind of error.
☞ For a list of error codes thrown by UltraLite ActiveX, see “ULSQLCode
enumeration” on page 142.
UltraLite ActiveX throws errors from only the ULDatabaseManager and
ULConnection objects. The following methods of ULDatabaseManager can
throw errors.
♦ CreateDatabase
♦ CreateDatabaseWithParms
♦ DropDatabase
♦ DropDatabaseWithParms
♦ OpenConnection
♦ OpenConnectionWithParms
All other errors and exceptions within UltraLite ActiveX are routed through
the ULConnection object.
☞ For more information about accessing error numbers from
ULDatabaseManager and ULConnection objects, see “ULConnection class”
on page 111 and “ULDatabaseManager class” on page 120.
The following sections explain how to implement error handling in
eMbedded Visual Basic and JScript.
90
Chapter 5. Understanding UltraLite ActiveX Development
With this key set, Pocket Internet Explorer will provide error notification
messages for JScript code that fails. Note that the line number reported may
not be reliable.
Set ErrorResume To suppress UltraLite ActiveX errors, the ULDatabaseManager and
property ULConnection objects provide the following two properties.
♦ ErrorResume is set to True to disable throwing subsequent errors.
♦ LastErrorCode returns the error code set by the last operation.
91
// JScript
DBMgr.ErrorResume = true; // Do not throw errors
Connection = DBMgr.OpenConnection( udb );
if ( DBMgr.LastErrorCode != 0 ) {
Connection = DBMgr.CreateDatabase( udb + usm );
if ( DBMgr.LastErrorCode != 0 ) {
alert("Connect with " + udb + usm + failed: " +
DBMgr.LastErrorCode );
}
}
92
Chapter 5. Understanding UltraLite ActiveX Development
User authentication
New users have to be added from an existing connection. As all UltraLite
databases are created with a default user ID and password of DBA and SQL,
respectively, you must first connect as this initial user.
You cannot change a user ID: you add a user and delete an existing user. A
maximum of four user IDs are permitted for each UltraLite database.
☞ For more information about granting or revoking connection authority,
see “GrantConnectTo method” on page 114 and “RevokeConnectFrom
method” on page 115.
93
Synchronizing UltraLite applications
Users of SQL Anywhere Studio 9.0 can synchronize UltraLite applications
with a central database. Synchronization requires the MobiLink
synchronization software included with SQL Anywhere Studio.
This section provides a brief introduction to synchronization and describes
some features of particular interest to users of UltraLite ActiveX.
Synchronization details can be found in the MobiLink Synchronization
User’s Guide and the UltraLite Database User’s Guide.
You can also find a working example of synchronization in the CustDB
sample application. For eMbedded Visual Basic, this sample is described in
“Tutorial: An UltraLite Application for PocketPC” on page 5. For JScript,
the sample is described in “Tutorial: An UltraLite Application for Pocket
IE” on page 43.
UltraLite ActiveX supports TCP/IP, HTTP, and HTTPS synchronization.
Synchronization is initiated by the UltraLite application. In all cases, you
use methods and properties of the ULConnection object to control
synchronization.
Note
To synchronize using encrypted synchronization (HTTPS) or to use en-
cryption over TCP/IP you must obtain the separately-licensable security
option. To order this option, see the card in your SQL Anywhere Studio
package or see http://www.sybase.com/detail?id=1015780.
☞ For more information, see “Welcome to SQL Anywhere Studio”
[Introducing SQL Anywhere Studio, page 4].
94
Chapter 5. Understanding UltraLite ActiveX Development
95
The following method shows users when synchronization states are
changed.
Private Sub UL_OnStateChange(ByVal newState As Long, _
ByVal oldState As Long)
prLine "OnStateChange new:" & newState & ", old: " &
oldState
End Sub
The following method shows users when the currently synchronized
table changes.
Private Sub UL_OnTableChange(ByVal newTableIndex As _
Long, ByVal numTables As Long)
prLine "OnTableChange index:" & newTableIndex & ",
#tables=" & numTables
End Sub
96
Chapter 5. Understanding UltraLite ActiveX Development
97
CHAPTER 6
About this chapter This chapter describes the UltraLite ActiveX API, a set of classes and
methods that allow you to write eMbedded Visual Basic or JScript code for
applications that use UltraLite databases. Each topic contains information
about a specific class, method, constant, or enum. The reference is organized
by class, with associated methods beneath.
Contents Topic: page
ULAuthStatusCode 104
99
Topic: page
100
Chapter 6. UltraLite ActiveX API Reference
IULColumns collection
A collection of ULColumn objects that provides you with metadata about
the column.
Properties
Prototype Description
101
IULIndexSchemas collection
A collection of ULIndexSchema objects that provides you with
ULIndexSchema information.
Properties
Prototype Description
Item (Index) as ULIn- Gets an index from the collection. Items are
dexSchema (read-only) indexed using 1-origin indexing. Index can
be a number from 1 to count.
Example You can enumerate the indexes on a table using the For Each statement in
eMbedded Visual Basic or the for ... in statement in JScript.
’ eMbedded Visual Basic
Dim index As ULIndexSchema
For Each index In TableSchema.Indexes
’use index
Next
// JScript
var index : UltraLite.ULIndexSchema;
var collection = TableSchema.Indexes;
for ( index in collection ) {
’ use index
}
102
Chapter 6. UltraLite ActiveX API Reference
IULPublicationSchemas collection
A collection of ULPublicationSchema objects that provides you with
information about ULPublicationSchema.
Properties
Prototype Description
103
ULAuthStatusCode
The ULAuthStatusCode is the auth_status synchronization parameter used
in the ULSyncResult object.
Constant Value
ulAuthUnknown 0
ulAuthValid 1000
ulAuthValidButExpiresSoon 2000
ulAuthExpired 3000
ulAuthInvalid 4000
ulAuthInUse 5000
104
Chapter 6. UltraLite ActiveX API Reference
ULColumn class
The ULColumn object allows you to get and set values from a table in a
database. Each column object represents a particular value in a table; the
row is determined by the ULTable object.
Prototype Description
Value As Variant Gets or sets the data value of this column in the
current row as Variant.
AppendByteChunk method
Prototype AppendByteChunk( _
byteArray , _
[ chunkSize ] _
) As Boolean
Member of UltraliteActiveX.ULColumn
Description Appends the buffer of bytes to the row’s column if the type is
ulTypeLongBinary or TypeBinary.
Parameters byteArray The array of bytes to be appended.
chunkSize The number of bytes to be appended. If not provided, the
length of byteArray is used.
Returns True if successful.
False if unsuccessful.
105
Errors set
Error Description
AppendStringChunk method
Prototype AppendStringChunk( chunk )
Member of UltraLiteActiveX.ULColumn
Description Appends the string to the column if the type is TypeLongString or
TypeString.
Parameters data A string to append to the existing string in a table.
Errors set
Error Description
GetByteChunk method
Prototype GetByteChunk (_
offset As Long, _
pByteArray , _
[ chunkSize ] _
) As Long
Member of UltraliteActiveX.ULColumn
Description Fills the buffer passed in, which should be an array, with the binary data in
the column. Suitable for BLOBS.
Parameters offset The offset into the underlying array of bytes. The source offset must
106
Chapter 6. UltraLite ActiveX API Reference
Error Description
GetStringChunk method
Prototype GetStringChunk( _
offset As Long, _
pStringObj, _
[ chunkSize ] _
) As Long
Member of UltraliteActiveX.ULColumn
Description Fills the string passed in with the binary data from the column. Suitable for
LONG VARCHAR columns.
Parameters offset The character offset into the underlying data from which you start
getting the String.
107
pStringObj The string array you want filled. This variant is passed by
reference.
chunkSize An optional parameter representing the number of characters to
retrieve.
Returns The number of characters copied. Room is left for a null termination
character and the length does not include that character.
Errors
Error Description
SetByteChunk method
Prototype SetByteChunk ( _
ByteArray , _
[ length ] _
) As Boolean
Member of UltraliteActiveX.ULColumn
108
Chapter 6. UltraLite ActiveX API Reference
Description Sets the value of the column in the database to the array of bytes in the data
field.
Parameters ByteArray An array of bytes of type Variant.
length The length of the array.
Returns True if successful.
False if unsuccessful.
Errors set
Error Description
SetToDefault method
Prototype SetToDefault( )
Member of UltraliteActiveX.IColumn
Description Sets the current column to its default value as defined by the database
schema. For example, an autoincrement column will be assigned the next
available value.
109
ULColumnSchema class
The ULColumnSchema object allows you to obtain metadata, the attributes
of a column, in a table. The attributes are independent of the data in the
table.
Properties
Prototype Description
DefaultValue As String Gets the value used if one was not provided
(read-only) when a row was inserted.
GlobalAutoIncrement As Indicates whether this column defaults to a
Boolean (read-only) global autoincrement value.
ID As Long(read-only) Gets the ID of the column.
OptimalIndex As ULIn- Gets the index with this column as its first
dexSchema (read-only) column.
Precision As Integer (read- Gets the precision value for the column if it is
only) of type ulTypeNumeric.
Scale As Long (read-only) Gets the scale value for the column .
Size As Long (read-only) Gets the column size for binary, numeric, and
character data types.
SQLType As ULSQLType Gets the SQL type assigned to the column when
(read-only) it was created.
110
Chapter 6. UltraLite ActiveX API Reference
ULConnection class
The ULConnection object represents an UltraLite database connection. It
provides methods to get database objects like tables, and to synchronize.
Example
Properties The
following are properties of ULConnection:
Prototype Description
DatabaseID As Long (write- Sets the identification number for the con-
only) nected database. When you write the
DatabaseID, you set the database ID value to
be used for global autoincrement columns.
111
Prototype Description
CancelSynchronize method
Prototype CancelSynchronize( )
Member of UltraliteActiveX.ULConnection
Description When called during synchronization, the method cancels the
synchronization. The user can only call this method during one of the
synchronization events.
ChangeEncryptionKey method
Prototype ChangeEncryptionKey( newkey As String )
Member of UltraliteActiveX.ULConnection
Description Encrypt the database with the specified key.
Parameters newkey The new encryption key value for the database.
Example When you call CreateDatabaseWithParms and pass in the parms object, with
a value in place for EncryptionKey, the database is created with encryption.
Another way to change the encryption key is by specifying the new
encryption key on the ULConnection object. In this example, “apricot” is
the key.
Connection.ChangeEncryptionKey( "apricot" )
112
Chapter 6. UltraLite ActiveX API Reference
Close method
Prototype Close( )
Member of UltraliteActiveX.ULConnection
Description Closes the connection to the database. No methods on the ULConnection
object or any other database object for this connection should be called after
this method is called. If a connection is not explicitly closed, it will be
implicitly closed when the application terminates.
Commit method
Prototype Commit( )
Member of UltraliteActiveX.ULConnection
Description Commits outstanding changes to the database. This is only useful if
AutoCommit is false.
For more information, see Autocommit under ULConnection “Properties.”
[UltraLite for MobileVB User’s Guide, page 89]
CountUploadRows method
Prototype CountUploadRows(
[ mask As Long = 0 ], _
[ threshold As Long = -1 ] _
) As Long
Member of UltraliteActiveX.ULConnection
Description Returns the number of rows that need to be uploaded when synchronization
next takes place.
Parameters mask An optional, unique identifier that refers to the publications to check.
Use 0 for all publications. If not specified, then the value is zero.
threshold An optional parameter representing the maximum number of
rows to count. Use -1 to indicate no maximum. If not specified, this value
is -1.
Returns Returns the number of rows that need to be uploaded in next
synchronization.
GetNewUUID method
Prototype GetNewUUID( ) As String
Member of UltraliteActiveX.ULConnection
Description Returns a new universally unique identifier in a string format. This string is
of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
113
Returns Each call returns a new UUID.
GetTable method
Prototype GetTable( name As String ) As ULTable
Member of UltraliteActiveX.ULConnection
Description Returns the ULTable object for the specified table. You must then open the
table before data can be read from it.
Parameters name The name of the table sought.
Returns Returns the ULTable object.
GrantConnectTo method
Prototype GrantConnectTo(
userid As String, _
password As String _
)
Member of UltraliteActiveX.ULConnection
Description Grants the specified user permission to connect to the database with the
given password.
Parameters userid The user ID being granted authority to connect.
password The password the user ID must specify for connecting.
LastDownloadTime method
Prototype LastDownloadTime( [mask As Long = 0 ] As Date
Member of UltraliteActiveX.ULConnection
Description Returns the time of last download for the publication(s).
Parameters mask An optional, unique identifier that refers to the publications to check.
Use 0 for all publications. If this parameter is omitted, 0 is used.
Returns The last download time in the form of a date.
PrepareStatement method
Prototype PrepareStatement( sqlStatement As String ) As ULPreparedStatement
Member of UltraliteActiveX.ULConnection
Description Prepares a SQL statement for execution.
Parameters sqlStatement The SQL statement to prepare.
Returns Returns a ULPreparedStatement. If there was a problem preparing the
statement, an error will be raised. The offset into the statement where the
114
Chapter 6. UltraLite ActiveX API Reference
ResetLastDownloadTime method
Prototype ResetLastDownloadTime( [ mask As Long ] )
Member of UltraliteActiveX.ULConnection
Description Resets the time of the most recent download for the publications specified in
the mask.
Parameters mask The mask of the publications to reset. The default is 0, specifying all
publications.
RevokeConnectFrom method
Prototype RevokeConnectFrom( userID As String )
Member of UltraliteActiveX.ULConnection
Description Revokes the specified user’s ability to connect to the database.
Parameters userid The user ID for the user to be revoked.
Rollback method
Prototype Rollback( )
Member of UltraliteActiveX.ULConnection
Description Rolls back outstanding changes to the database. This is only useful if
AutoCommit is false.
StartSynchronizationDelete method
Prototype StartSynchronizationDelete( )
Member of UltraliteActiveX.ULConnection
Description Once StartSynchronizationDelete is called, all delete operations are again
synchronized.
StopSynchronizationDelete method
Prototype StopSynchronizationDelete( )
Member of UltraliteActiveX.ULConnection
Description Prevents delete operations from being synchronized. This is useful for
deleting old information from an UltraLite database to save space, while not
deleting this information on the consolidated database.
115
StringToUUID method
Prototype StringToUUID( s_uuid As String )
Member of UltraliteActiveX.ULConnection
Description Converts the universally unique identifier represented as a String in the form
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx to a Byte array of 16 bytes.
Parameters s_uuid A Universally Unique Identifier passed in as a string. You can
obtain a new string UUID using GetNewUUID.
Example The following example will convert the string form of the UUID
0a141e28-323c-4650-5a64-6e78828c96a0 to a binary array:
’ eMbedded Visual Basic
Dim buff(1 to 16) As Byte
conn.StringToUUID( "0a141e28-323c-4650-5a64-6e78828c96a0",
VarPtr(buff(1)) )
Synchronize method
Prototype Synchronize( [show-progress As Boolean ] )
Member of UltraliteActiveX.ULConnection
Description Synchronizes a consolidated database using MobiLink. This function does
not return until synchronization is complete, but you can be notified of
events if the connection was declared WithEvents.
Parameters show-progress An optional parameter whose value may be true or false.
Set this to true to show the progress of synchronization as it happens.
Default is false.
UUIDToString method
Prototype UUIDToString( buffer_16_bytes ) As String
Member of UltraliteActiveX.ULConnection
Description Expects a VarPtr to a buffer of 16 bytes. Converts this buffer to a string in
the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. The buffer must be
declared (1 to 16) As Byte (that is, an array of 16 bytes). Visual Basic is
unable to check the bounds for this buffer so if it is not big enough, the
application could overwrite memory.
Parameters buffer_16_bytes An array of 16 bytes containing a UUID.
Returns Each call returns a string of the form
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
116
Chapter 6. UltraLite ActiveX API Reference
ULConnectionParms class
The ULConnectionParms object allows you to set userID, password, schema
file, file on your desktop, and numerous other parameters that specify your
connection.
Properties
The ULConnectionParms class specifies parameters for opening a
connection to an UltraLite database.
In UltraLite ActiveX, you can use the ULConnectionParms object and set
your connection properties in your code. You use the ULConnectionParms
object in conjunction with the
ULDatabaseManager.CreateDatabaseWithParms and
ULDatabaseManager.OpenConnectionWithParms methods.
Note
Databases are created with a single authenticated user, DBA, whose initial
password is SQL. By default, connections are opened using the user ID
DBA and password SQL.
☞ For more information about the meaning of these parameters, see
“Connection Parameters” [UltraLite Database User’s Guide, page 49].
Prototype Description
CacheSize As String (read- The size of the cache. CacheSize values are
write) specified in bytes. Use the suffix k or K
for kilobytes and use the suffix m or M for
megabytes. The default cache size is sixteen
pages. Given a default page size of 4 KB, the
default cache size is 64 KB.
☞ See “Cache Size connection parameter”
[UltraLite Database User’s Guide, page 66].
117
Prototype Description
118
Chapter 6. UltraLite ActiveX API Reference
Prototype Description
119
ULDatabaseManager class
The ULDatabaseManager class is used to manage connections and
databases. Your application should only have one instance of this object.
Creating a database and establishing a connection to it is a necessary first
step in using UltraLite. It is suggested that you use
CreateDatabaseWithParms, OpenConnectionWithParms and
DropDatabaseWithParms, and include checks in your code to ensure that
you are connected properly before attempting any DML with the database.
Parms or no parms?
Two types of methods exist for creating, opening and dropping connections
to your database: Methods WithParms and methods that do not use the
ULConnectionParms object. Methods WithParms allow you to use a
ULConnectionParms object to manipulate connection parameters with ease
and accuracy. Methods that do not use the ULConnectionParms object
require that you can successfully create a connections string and use that
connection string in a CreateDatabase, OpenConnection or DropDatabase
method.
Properties
The following are properties of ULDatabaseManager:
Prototype Description
LastErrorCode As Gets the last error number, and allows you to clear the
SQLCodeCon- previous error code.
stants
CreateDatabase method
CreateDatabase creates a new database and returns a connection to it.
Prototype CreateDatabase( parms As String ) As ULConnection
Member of UltraliteActiveX.ULDatabaseManager
Description Creates a new database and returns a connection to it. It fails if the specified
database already exists. A valid schema file must be specified to successfully
120
Chapter 6. UltraLite ActiveX API Reference
Caution
Only one database may be active at a given time. Attempts to create a
different database while other connections are open will result in an error.
☞ For more information about ApplyFile, see “ULDatabaseSchema class”
on page 128 and “ApplyFile method” on page 129.
Parameters parms A semicolon-separated list of database creation parameters.
☞ For information about connection parameters, see “Connection
Parameters” [UltraLite Database User’s Guide, page 49].
Returns Returns a connection to a newly created UltraLite database.
Examples The example below uses CreateObject to create and open a new database.
’ eMbedded Visual Basic
open_parms = "file_name=\tutCustomer.udb"
schema_parms = open_parms & ";" & "schema_name=\tutCustomer.usm"
Set DatabaseMgr = CreateObject("UltraLite.ULDatabaseManager")
Set Connection = DatabaseMgr.CreateDatabase(schema_parms)
// JScript
open_parms = "file_name=\\tutCustomer.udb";
schema parms = open_parms + ";" + "schema_name=\\
tutCustomer.usm"
DatabaseMgr = new ActiveXObject("UltraLite.ULDatabaseManager")
Set Connection = DatabaseMgr.CreateDatabase(schema_parms);
The example below shows how you can create a ULDatabaseManager with
events. This tactic is used for showing synchronization progress.
This functionality is only available with eMbedded Visual Basic.
☞ For more information about showing synchronization progress, see
“Monitoring synchronization progress” on page 95.
’eMbedded Visual Basic
Set DBMgr =
CreateObjectWithEvents("UltraLite.ULDatabaseManager",
"_")
CreateDatabaseWithParms method
CreateDatabaseWithParms creates a new database using a connection
parameter object, and returns a connection to it.
121
Prototype CreateDatabaseWithParms( parms As ULConnection-
Parms ) As ULConnection
Member of UltraliteActiveX.ULDatabaseManager
Description Creates a new database and returns a connection to it. It fails if the specified
database already exists. A valid schema file must be specified to successfully
create a database. To alter the schema of an existing database, use the
ULDatabaseSchema.ApplyFileWithParms method.
Caution
Only one database may be active at a given time. Attempts to create a
different database while other connections are open will result in an error.
Parameters parms A ULConnectionParms object that holds a set of connection
parameters.
Returns Returns a connection to a newly created UltraLite database. Fails if the
specified database already exists.
Examples The following example assumes you have placed the ULConnectionParms
object on your form, named it LoginParms and have specified the database
locations and schema locations in the Connection parms properties window.
The example below uses CreateDatabaseWithParms to create and open a
new database.
’ eMbedded Visual Basic
’ Use CreateObject in to get an instance of the
ULDatabaseManager object
Set DatabaseMgr = CreateObject("UltraLite.ULDatabaseManager")
’ Use CreateObject to get an instance of the ULConnectionParms
object
Dim LoginParms As ULConnectionParms
Set LoginParms = CreateObject("UltraLite.ULConnectionParms")
LoginParms.DatabaseOnCE = "/tutorial/tutorial.udb"
LoginParms.SchemaOnCE = "/tutorial/tutorial.usm"
’ Drop the existing database and create a new database
Call DatabaseMgr.DropDatabaseWithParms( LoginParms )
Set Connection = DatabaseMgr.CreateDatabaseWithParms(LoginParms)
// JScript
’ get an instance of the ULDatabaseManager object
DatabaseMgr = new ActiveXObject("UltraLite.ULDatabaseManager");
var LoginParms;
LoginParms = new ActiveXObject("UltraLite.ULConnectionParms");
LoginParms.DatabaseOnCE = "//tutorial//tutorial.udb";
LoginParms.SchemaOnCE = "//tutorial//tutorial.usm";
’ Drop the existing database and create a new database
DatabaseMgr.DropDatabaseWithParms( LoginParms );
Connection = DatabaseMgr.CreateDatabaseWithParms( LoginParms );
122
Chapter 6. UltraLite ActiveX API Reference
DropDatabase method
The DropDatabase method deletes a database file.
Prototype DropDatabase( parms As String )
Member of UltraliteActiveX.ULDatabaseManager
Description Deletes the database file. All information in the database file is lost. Fails if
the specified database does not exist, or if there exist open connections at the
time of DropDatabase is executed.
Parameters parms The filename for the database.
Example The following example drops a database:
’ eMbedded Visual Basic
open_parms = "ce_file=\tutCustomer.udb"
DropDatabase(open_parms)
// JScript
open_parms = "ce_file=\\tutCustomer.udb";
DropDatabase( open_parms );
DropDatabaseWithParms method
The DropDatabaseWithParms method deletes a database file.
Prototype DropDatabaseWithParms( parms As ULConnectionParms )
Member of UltraliteActiveX.ULDatabaseManager
Description Deletes the database file. All information in the database file is lost.
Parameters parms The ULConnectionParms object containing vital connection
parameters .
Example The following example assumes you have declared and instantiated a
ULConnectionParms object named LoginParms and used it to specify the
database location.
’ eMbedded Visual Basic
Call DatabaseMgr.DropDatabaseWithParms( LoginParms )
// JScript
DatabaseMgr.DropDatabseWithParms( LoginParms );
123
OnReceive event
Prototype OnReceive(
nBytes As Long, _
nInserts As Long, _
nUpdates As Long, _
nDeletes As Long _
)
Member of UltraliteActiveX.ULDatabaseManager
OnSend event
Prototype OnSend(
nBytes As Long,
nInserts As Long,
nUpdates As Long,
nDeletes As Long
)
Member of UltraliteActiveX.ULDatabaseManager
Description Reports upload information from the remote database via MobiLink to the
consolidated database. This event may be called several times.
Parameters nBytes Cumulative count of bytes sent by the remote application to the
consolidated database via MobiLink.
nInserts Cumulative count of inserts sent by the remote application to the
consolidated database via MobiLink.
124
Chapter 6. UltraLite ActiveX API Reference
OnStateChange event
Prototype OnStateChange(
newState As ULSyncState, _
oldState As ULSyncState _
)
Member of UltraliteActiveX.ULDatabaseManager
Description This event is called whenever the state of the synchronization changes.
Parameters newState The state that the synchronization process is about to enter.
oldState The state that the synchronization process just completed.
Example ’ eMbedded Visual Basic
Private Sub _OnStateChange(ByVal newState As Long, ByVal
oldState As Long)
prLine "OnStateChange new:" & newState & ", old: " &
oldState
End Sub
OnTableChange event
Prototype OnTableChange(
newTableIndex As Long, _
numTables As Long _
)
Member of UltraliteActiveX.ULDatabaseManager
125
numTables The number of tables eligible to be synchronized.
Example ’ eMbedded Visual Basic
Private Sub _OnTableChange(ByVal newTableIndex As Long, ByVal
numTables As Long)
prLine "OnTableChange index:" & newTableIndex & ", #tables="
& numTables
End Sub
OpenConnection method
Prototype OpenConnection( connparms As string ) As ULConnection
Member of UltraliteActiveX.ULDatabaseManager
Description If a database exists, use this method to connect to the database. If a database
does not exist, or the connection parameters are invalid, the call will fail.
Use the error object to determine why the call failed.
The function returns a ULConnection object which provides an open
connection to a specified UltraLite database. The database filename is
specified using the connparms string. Parameters are specified using a
sequence of name=value pairs. If no user ID or password is given, the
default is used.
Parameters connparms The parameter used to establish a connection to a database.
Parameters are specified as a semicolon separated list of keyword=value
pairs. If no user ID or password is given, the default is used.
Returns The ULConnection object is returned if the connection was successful.
Example The example below shows how to use connection parameters in the
OpenConnection method.
’ eMbedded Visual Basic
open_parms = "ce_file = \tutCustomer.udb"
Set DatabaseMgr = CreateObject("UltraLite.ULDatabaseManager")
Set Connection = DatabaseMgr.OpenConnection(open_parms)
// JScript
open_parms = "ce_file = \\tutCustomer.udb";
DatabaseMgr = new ActiveXObject("UltraLite.ULDatabaseManager");
Connection = DatabaseMgr.OpenConnection(open_parms);
OpenConnectionWithParms method
Prototype OpenConnectionWithParms( connparms As ULConnection-
Parms) As ULConnection
Member of UltraliteActiveX.ULDatabaseManager
126
Chapter 6. UltraLite ActiveX API Reference
does not exist, or the connection parameters are invalid, the call will fail.
Use the error object to determine why the call failed.
The function returns a ULConnection object which provides an open
connection to a specified UltraLite database. The database filename is
specified using the connparms object. Parameters are specified using a
sequence of name=value pairs. If no user ID or password is given, the
default is used.
Parameters connparms The parameters defining this connection.
Returns The ULConnection object is returned if the connection was successful.
Example The following example assumes you have created a ULConnectionParms
object LoginParms and have specified the database locations and schema
locations.
’ eMbedded Visual Basic
Set DatabaseMgr = CreateObject("UltraLite.ULDatabaseManager")
Set Connection = DatabaseMgr.OpenConnection(LoginParms)
// JScript
DatabaseMgr = new ActiveXObject("UltraLite.ULDatabaseManager");
Connection = DatabaseMgr.OpenConnection(LoginParms);
127
ULDatabaseSchema class
The ULDatabaseSchema object allows you to obtain the attributes of the
database to which you are connected.
Properties
The following are properties of ULDatabaseSchema:
Prototype Description
DateFormat As String (read-only) Gets the format for dates retrieved from
the database; ‘YYYY-MM-DD’ is the
default. The format of the date retrieved
depends on the format used when you
created the schema file.
TimeFormat As String (read-only) Gets the format for times retrieved from
the database.
128
Chapter 6. UltraLite ActiveX API Reference
Prototype Description
ApplyFile method
Prototype ApplyFile( parms As String ) As Boolean
Member of UltraliteActiveX.ULDatabaseSchema
Description Changes the schema of this database. Parms points to the schema file(s) you
are applying to the database. This method is only useful on those occasions
where you want to modify your existing database structure.
Caution
ApplyFile is very safe in the hands of an informed programmer. Do not
delete columns unthinkingly unless you are willing to accept data loss,
as data loss can occur under a number of circumstances including (1) if
columns are deleted, or (2) if the data type for a column is changed to an
incompatible type or (3) if you upgrade an 8.0.2 database using ApplyFile
in UltraLite 9.0.
Parameters parms The files containing the changes you wish to make to your database
schema.
Returns True if successful.
False if unsuccessful.
Example DatabaseSchema.ApplyFile( _
"schema_file=MySchemaFile.usm;palm_schema=MySchema" )
ApplyFileWithParms method
Prototype ApplyFileWithParms( parms As ULConnectionParms ) As Boolean
Member of UltraliteActiveX.ULDatabaseSchema
Description Upgrades the schema of this database using the parameter object Parms,
which points to the schema file(s) you are applying to the database. This
method is only useful on those occasions where you want to modify your
existing database structure.
129
Caution
ApplyFileWithParms is very safe in the hands of an informed programmer.
Do not delete columns unthinkingly unless you are willing to accept data
loss, as data loss can occur under a number of circumstances including (1)
if columns are deleted, or (2) if the data type for a column is changed to an
incompatible type or (3) if you upgrade an 8.0.2 database using ApplyFile
in UltraLite 9.0.
Parameters parms The object identifying the schema file to apply.
Returns True if successful.
False if unsuccessful.
130
Chapter 6. UltraLite ActiveX API Reference
ULIndexSchema class
The ULIndexSchema object allows you to obtain the attributes of an index.
An index is an ordered set of columns by which data in a table will be
sorted. The primary use of an index is to order the data in a table by one or
more columns.
An index can be a foreign key, which is used to maintain referential integrity
in a database.
Properties
Prototype Description
131
ULPreparedStatement class
The ULPreparedStatement represents a pre-compiled SQL statement ready
for execution. You can use Prepared Statement to run a SQL query. You can
also use the ULPreparedStatement to execute the same statement multiple
times using numerous input parameters. Since the prepared statement is
precompiled, any further additions beyond the first execution take very little
extra processing. Use ULPreparedStatement and Dynamic SQL when you
want relatively fast DML over multiple rows.
Properties
Prototype Description
AppendByteChunk method
Prototype AppendByteChunk( _
parameter_id As Long, _
Array , _
[ chunkSize ] _
) As Boolean
Member of UltraliteActiveX.ULPreparedStatement
Description Appends the buffer of bytes to the row’s column if the type is
ulTypeLongBinary.
Parameters parameter_id The 1-based parameter number to set.
data The array of bytes to be appended.
chunkSize The number of bytes to be appended. If not provided, the
length of byteArray is used.
Returns True if successful.
132
Chapter 6. UltraLite ActiveX API Reference
False if unsuccessful.
Errors set
Error Description
AppendStringChunk method
Prototype AppendStringChunk(
parameter_id As Long ,
chunk )
Member of UltraLiteActiveX.ULPreparedStatement
Error Description
Close method
Prototype Close( )
Member of UltraLiteActiveX.ULPreparedStatement
ExecuteQuery method
Prototype ExecuteQuery( ) As ULResultSet
Member of UltraliteActiveX.ULPreparedStatement
133
ExecuteStatement method
Prototype ExecuteStatement( ) As Long
Member of UltraliteActiveX.ULPreparedStatement
SetNullParameter method
Prototype SetNullParameter( parameter_id As Long )
Member of UltraliteActiveX.ULPreparedStatement
SetParameter method
Prototype SetParameter(
parameter_id As Long
val
)
Member of UltraliteActiveX.ULPreparedStatement
134
Chapter 6. UltraLite ActiveX API Reference
ULPublicationSchema class
The ULPublicationSchema object allows you to obtain the attributes of a
publication.
Properties
Prototype Description
135
ULResultSet class
The ULResultSet object moves over rows returned by a SQL query. Since
the ULResultSet object contains the data returned by a query, you must
refresh any query resultset after you have performed DML operations such
as INSERT, UPDATE or DELETE. To do this, you should perform
ExecuteQuery after you perform ExecuteStatement.
Properties
Prototype Description
Close method
Prototype Close()
Member of UltraliteActiveX.ULResultSet
Description Frees all resources associated with this object.
136
Chapter 6. UltraLite ActiveX API Reference
GetByteChunk method
Prototype GetByteChunk(
index As Long, _
offset As Long, _
data, _
[ data_len As Long ] _
) As Long
Member of UltraliteActiveX.ULResultSet
Description Fills the buffer passed in (which should be an array) with the binary data in
the column. Suitable for BLOBS.
Parameters index The 1-based ordinal of the column containing the binary data.
offset The offset into the underlying array of bytes. The source offset must
be greater than or equal to 0, otherwise a SQLE_INVALID_PARAMETER
error will be raised. A buffer bigger than 64K is also permissible.
data A pointer to an array of bytes.
data_len The length of the buffer, or array. The data_len must be greater
than or equal to 0.
Returns The number of bytes read.
Errors set
Error Description
137
GetStringChunk method
Prototype GetStringChunk(
index As Long, _
offset As Long, _
pStringObj, _
[ chunkSize ] ) As Long
Member of UltraliteActiveX.ULResultSet
Description Fills the string passed in with the binary data in the column. Suitable for
Long Varchars.
Parameters index The 1-based column ID of the target column.
offset The character offset into the underlying data from which you start
getting the string.
pStringObj The string you want returned. This variant is passed by
reference.
chunkSize An optional parameter representing the number of characters to
retrieve.
Returns The number of characters copied. Room is left for a null termination
character and the length does not include that character.
Gets BLOB data from a binary or long binary column.
Errors set
Error Description
ulSQLE_- The error occurs if the column data type is not CHAR
CONVERSION_- or LONG VARCHAR
ERROR
MoveAfterLast method
Prototype MoveAfterLast( )
Member of UltraliteActiveX.ULResultSet
Description Moves to a position after the last row of the ULResultSet.
Returns True if successful.
138
Chapter 6. UltraLite ActiveX API Reference
False if unsuccessful. The method fails, for example, if there are no rows.
MoveBeforeFirst method
Prototype MoveBeforeFirst( )
Member of UltraliteActiveX.ULResultSet
Description Moves to a position before the first row.
Returns True if successful.
False if unsuccessful. The method fails, for example, if there are no rows.
MoveFirst method
Prototype MoveFirst( ) As Boolean
Member of UltraliteActiveX.ULResultSet
Description Moves to the first row.
Returns True if successful.
False if unsuccessful. The method fails, for example, if there are no rows.
MoveLast method
Prototype MoveLast( )
Member of UltraliteActiveX.ULResultSet
Description Moves to the last row.
Returns True if successful.
False if unsuccessful. The method fails, for example, if there are no rows.
MoveNext method
Prototype MoveNext( ) As Boolean
Member of UltraliteActiveX.ULResultSet
Description Moves to the next row.
Returns True if successful.
False if unsuccessful. The method fails, for example, if there are no rows.
MovePrevious method
Prototype MovePrevious( ) As Boolean
Member of UltraliteActiveX.ULResultSet
Description Moves to the previous row.
139
Returns True if successful.
False if unsuccessful. The method fails, for example, if there are no rows.
MoveRelative method
Prototype MoveRelative( index As Long ) As Boolean
Member of UltraliteActiveX.ULResultSet
Description Moves a certain number of rows relative to the current row. Relative to the
current position of the cursor in the resultset, positive index values move
forward in the resultset, negative index values move backward in the
resultset and zero does not move the cursor.
Parameters index The number of rows to move. The value can be positive, negative, or
zero.
Returns True if successful.
False if unsuccessful. The method fails, for example, if there are no rows.
IsNull method
Prototype IsNull( index As Integer ) As Boolean
Member of UltraliteActiveX.ULResultSet
Description Indicates whether this column contains a null value.
Parameters index The column index value.
Returns True if the value is Null.
140
Chapter 6. UltraLite ActiveX API Reference
ULResultSetSchema class
The ULResultSetSchema provides information about the schema of the
result set.
Properties
Prototype Description
ColumnScale As Integer Gets the scale of the datatype for the column
(read-only) if it is numeric.
ColumnSize As Integer (read- Gets the size of the datatype for the column.
only)
GetColumnID method
Prototype GetColumnID( col_name As String ) As Long
Member of UltraliteActiveX.ULResultSetSchema
Description Get the column id for a named column.
Parameters col_name The column name for which an id is sought.
Returns GetColumnID returns the column ID for the named column.
141
ULSQLCode enumeration
The ULSQLCode constants identify SQL codes that may be reported by
UltraLite.
For a description of the errors, see the Adaptive Server Anywhere Error
Messages book.
Constant Value
ulSQLE_AGGREGATES_NOT_ALLOWED -150
ulSQLE_ALIAS_NOT_UNIQUE -830
ulSQLE_ALIAS_NOT_YET_DEFINED -831
ulSQLE_BAD_ENCRYPTION_KEY -840
ulSQLE_BAD_PARAM_INDEX -689
ulSQLE_CANNOT_ACCESS_FILE -602
ulSQLE_CANNOT_CHANGE_USER_NAME -867
ulSQLE_CANNOT_MODIFY -191
ulSQLE_CANNOT_EXECUTE_STMT -111
ulSQLE_COLUMN_AMBIGUOUS -144
ulSQLE_COLUMN_CANNOT_BE_NL -195
ulSQLE_COLUMN_IN_INDEX -127
ulSQLE_COLUMN_NOT_FOUND -143
ulSQLE_COMMUNICATIONS_ERROR -85
ulSQLE_CONNECTION_NOT_FOUND -108
ulSQLE_CONVERSION_ERROR -157
ulSQLE_CURSOROP_NOT_ALLOWED -187
ulSQLE_CURSOR_ALREADY_OPEN -172
ulSQLE_CURSOR_NOT_OPEN -180
ulSQLE_DATABASE_ERROR -301
ulSQLE_DATABASE_NEW 123
ulSQLE_DATABASE_NOT_CREATED -645
ulSQLE_DATABASE_NOT_FOUND -83
142
Chapter 6. UltraLite ActiveX API Reference
Constant Value
ulSQLE_DATABASE_UPGRADE_FAILED -672
ulSQLE_DATABASE_UPGRADE_NOT_- -673
POSSIBLE
ulSQLE_DATATYPE_NOT_ALLOWED -624
ulSQLE_DBSPACE_FL -604
ulSQLE_DIV_ZERO_ERROR -628
ulSQLE_DOWNLOAD_CONFLICT -839
ulSQLE_DROP_DATABASE_FAILED -651
ulSQLE_DYNAMIC_MEMORY_EXHAUSTED -78
ulSQLE_ENGINE_ALREADY_RUNNING -96
ulSQLE_ENGINE_NOT_MTIUSER -89
ulSQLE_ERROR -300
ulSQLE_ERROR_CALLING_FUNCTION -622
ulSQLE_EXPRESSION_ERROR -156
ulSQLE_IDENTIFIER_TOO_LONG -250
ulSQLE_INDEX_NOT_FOUND -183
ulSQLE_INDEX_NOT_UNIQUE -196
ulSQLE_INTERRUPTED -299
ulSQLE_INVALID_AGGREGATE_- -862
PLACEMENT
ulSQLE_INVALID_FOREIGN_KEY -194
ulSQLE_INVALID_FOREIGN_KEY_DEF -113
ulSQLE_INVALID_GROUP_SELECT -149
ulSQLE_INVALID_LOGON -103
ulSQLE_INVALID_OPTION_SETTING -201
ulSQLE_INVALID_ORDER -152
ulSQLE_INVALID_ORDERBY_COLUMN -854
ulSQLE_INVALID_PARAMETER -735
143
Constant Value
ulSQLE_INVALID_SQL_IDENTIFIER -760
ulSQLE_INVALID_STATEMENT -130
ulSQLE_LOCKED -210,
ulSQLE_MEMORY_ERROR -309
ulSQLE_METHOD_CANNOT_BE_CALLED -669
ulSQLE_NAME_NOT_UNIQUE -110
ulSQLE_NOERR 0
ulSQLE_NOTFOUND 100
ulSQLE_NOT_IMPLEMENTED -134
ulSQLE_NO_CURRENT_ROW -197
ulSQLE_NO_INDICATOR -181
ulSQLE_OVERFLOW_ERROR -158
ulSQLE_PERMISSION_DENIED -121
ulSQLE_PRIMARY_KEY_NOT_UNIQUE -193
ulSQLE_PRIMARY_KEY_VALUE_REF -198
ulSQLE_PUBLICATION_NOT_FOUND -280
ulSQLE_RESOURCE_GOVERNOR_- -685
EXCEEDED
ulSQLE_ROW_DROPPED_DURING_- 130
SCHEMA_UPGRADE
ulSQLE_SERVER_SYNCHRONIZATION_- -857
ERROR
ulSQLE_START_STOP_DATABASE_DENIED -75
ulSQLE_STATEMENT_ERROR -132
ulSQLE_SYNTAX_ERROR -131
ulSQLE_STRING_RIGHT_TRUNCATION -638
ulSQLE_TABLE_HAS_PUBLICATIONS -281
ulSQLE_TABLE_IN_USE -214
ulSQLE_TABLE_NOT_FOUND -141
144
Chapter 6. UltraLite ActiveX API Reference
Constant Value
ulSQLE_TOO_MANY_CONNECTIONS -102
ulSQLE_TRALITE_OBJ_CLOSED -908
ulSQLE_UNABLE_TO_CONNECT_OR_START -764
ulSQLE_UNABLE_TO_START_DATABASE -82
ulSQLE_UNCOMMITTED_TRANSACTIONS -755
ulSQLE_UNKNOWN_FUNC -148
ulSQLE_UNKNOWN_USERID -140
ulSQLE_UNSUPPORTED_CHARACTER_SET_- -869
ERROR
ulSQLE_UPLOAD_FAILED_AT_SERVER -794
ulSQLE_WRONG_PARAMETER_COUNT -154
145
ULSQLType enumeration
ULSQLType lists the available UltraLite SQL database types used as table
column types.
ulTypeLong Integer 1
ulTypeUnsignedLong SmallInt 2
ulTypeShort UnsignedInteger 3
ulTypeUnsignedShort UnsignedSmallInt 4
ulTypeBig Big 5
ulTypeUnsignedBig UnsignedBig 6
ulTypeByte Byte 7
ulTypeBit Bit 8
ulTypeDateTime Time 9
ulTypeDate Date 10
ulTypeTime Timestamp 11
ulTypeDouble Double 12
ulTypeReal Real 13
ulTypeNumeric (Var)Binary 14
ulTypeBinary LongBinary 15
ulTypeString (Var)Char 16
ulTypeLongString LongVarchar 17
ulTypeLongBinary Numeric 18
146
Chapter 6. UltraLite ActiveX API Reference
ULStreamErrorCode enumeration
The ULStreamErrorCode constants identify constants you can use to specify
the ULStreamErrorCode.
Constant Value
ulStreamErrorCodeNone 0
ulStreamErrorCodeParameter 1
ulStreamErrorCodeParameterNotUint32 2
ulStreamErrorCodeParameterNotUint32Range 3
ulStreamErrorCodeParameterNotBoolean 4
ulStreamErrorCodeParameterNotHex 5
ulStreamErrorCodeMemoryAllocation 6
ulStreamErrorCodeParse 7
ulStreamErrorCodeRead 8
ulStreamErrorCodeWrite 9
ulStreamErrorCodeEndWrite 10
ulStreamErrorCodeEndRead 11
ulStreamErrorCodeNotImplemented 12
ulStreamErrorCodeWouldBlock 13
ulStreamErrorCodeGenerateRandom 14
ulStreamErrorCodeInitRandom 15
ulStreamErrorCodeSeedRandom 16
ulStreamErrorCodeCreateRandomObject 17
ulStreamErrorCodeShuttingDown 18
ulStreamErrorCodeDequeuingConnection 19
ulStreamErrorCodeSecureCertificateRoot 20
ulStreamErrorCodeSecureCertificateCompanyName 21
ulStreamErrorCodeSecureCertificateChainLength 22
ulStreamErrorCodeSecureCertificateRef 23
ulStreamErrorCodeSecureCertificateNotTrusted 24
147
Constant Value
ulStreamErrorCodeSecureDuplicateContext 25
ulStreamErrorCodeSecureSetIo 26
ulStreamErrorCodeSecureSetIoSemantics 27
ulStreamErrorCodeSecureCertificateChainFunc 28
ulStreamErrorCodeSecureCertificateChainRef 29
ulStreamErrorCodeSecureEnableNonBlocking 30
ulStreamErrorCodeSecureSetCipherSuites 31
ulStreamErrorCodeSecureSetChainNumber 32
ulStreamErrorCodeSecureCertificateFileNotFound 33
ulStreamErrorCodeSecureReadCertificate 34
ulStreamErrorCodeSecureReadPrivateKey 35
ulStreamErrorCodeSecureSetPrivateKey 36
ulStreamErrorCodeSecureCertificateExpiryDate 37
ulStreamErrorCodeSecureExportCertificate 38
ulStreamErrorCodeSecureAddCertificate 39
ulStreamErrorCodeSecureTrustedCertificateFileNotFound 40
ulStreamErrorCodeSecureTrustedCertificateRead 41
ulStreamErrorCodeSecureCertificateCount 42
ulStreamErrorCodeSecureCreateCertificate 43
ulStreamErrorCodeSecureImportCertificate 44
ulStreamErrorCodeSecureSetRandomRef 45
ulStreamErrorCodeSecureSetRandomFunc 46
ulStreamErrorCodeSecureSetProtocolSide 47
ulStreamErrorCodeSecureAddTrustedCertificate 48
ulStreamErrorCodeSecureCreatePrivateKeyObject 49
ulStreamErrorCodeSecureCertificateExpired 50
ulStreamErrorCodeSecureCertificateCompanyUnit 51
ulStreamErrorCodeSecureCertificateCommonName 52
148
Chapter 6. UltraLite ActiveX API Reference
Constant Value
ulStreamErrorCodeSecureHandshake 53
ulStreamErrorCodeHttpVersion 54
ulStreamErrorCodeSecureSetReadFunc 55
ulStreamErrorCodeSecureSetWriteFunc 56
ulStreamErrorCodeSocketHostNameNotFound 57
ulStreamErrorCodeSocketGetHostByAddr 58
ulStreamErrorCodeSocketLocalhostNameNotFound 59
ulStreamErrorCodeSocketCreateTcpip 60
ulStreamErrorCodeSocketCreateUdp 61
ulStreamErrorCodeSocketBind 62
ulStreamErrorCodeSocketCleanup 63
ulStreamErrorCodeSocketClose 64
ulStreamErrorCodeSocketConnect 65
ulStreamErrorCodeSocketGetName 66
ulStreamErrorCodeSocketGetOption 67
ulStreamErrorCodeSocketSetOption 68
ulStreamErrorCodeSocketListen 69
ulStreamErrorCodeSocketShutdown 70
ulStreamErrorCodeSocketSelect 71
ulStreamErrorCodeSocketStartup 72
ulStreamErrorCodeSocketPortOutOfRange 73
ulStreamErrorCodeLoadNetworkLibrary 74
ulStreamErrorCodeActsyncNoPort 75
ulStreamErrorCodeHttpExpectedPost 89
149
ULStreamErrorContext enumeration
The ULStreamErrorContext constants identify constants you can use to
specify ULStreamErrorContext. The ULStreamErrorContext is the network
operation performed when the stream error happens.
Constant Value
ulStreamErrorContextUnknown 0
ulStreamErrorContextRegister 1
ulStreamErrorContextUnregister 2
ulStreamErrorContextCreate 3
ulStreamErrorContextDestroy 4
ulStreamErrorContextOpen 5
ulStreamErrorContextClose 6
ulStreamErrorContextRead 7
ulStreamErrorContextWrite 8
ulStreamErrorContextWriteFlush 9
ulStreamErrorContextEndWrite 10
ulStreamErrorContextEndRead 11
ulStreamErrorContextYield 12
ulStreamErrorContextSoftshutdown 13
150
Chapter 6. UltraLite ActiveX API Reference
ULStreamErrorID enumeration
The ULStreamErrorID is an enumeration of the possible network layers that
caused an error in an unsuccessful synchronization.
Constant Value
ulStreamErrorIDTcpip 0
ulStreamErrorIDSerial 1
ulStreamErrorIDFake 2
ulStreamErrorIDNettech 5
ulStreamErrorIDRimbb 6
ulStreamErrorIDHttp 7
ulStreamErrorIDHttps 8
ulStreamErrorIDDhCast 9
ulStreamErrorIDSecure 10
ulStreamErrorIDCerticom 11
ulStreamErrorIDJavaCerticom 12
ulStreamErrorIDCerticomSsl 13
ulStreamErrorIDCerticomTls 14
ulStreamErrorIDWirestrm 15
ulStreamErrorIDWireless 16
ulStreamErrorIDReplay 17
ulStreamErrorIDStrm 18
ulStreamErrorIDUdp 19
ulStreamErrorIDEmail 20
ulStreamErrorIDFile 21
ulStreamErrorIDActivesync 22
ulStreamErrorIDRsaTls 23
ulStreamErrorIDJavaRsa 24
151
ULStreamType enumeration
The ULStreamType constants identify constants you can use to specify
stream type. These represent the types of MobiLink synchronization streams
you can use for synchronization.
152
Chapter 6. UltraLite ActiveX API Reference
ULSyncParms class
The attributes set for the ULSyncParms object determine how the database
synchronizes with the consolidated or desktop database. Attributes that are
read-only reflect the status of the last synchronization.
Properties
The following are properties of ULSyncParms:
Prototype Description
153
Prototype Description
AddAuthenticationParm method
Prototype AddAuthenticationParm( BSTR parm )
Member of UltraliteActiveX.ULSyncParms
ClearAuthenticationParms method
Prototype ClearAuthenticationParms( )
Member of UltraliteActiveX.ULSyncParms
154
Chapter 6. UltraLite ActiveX API Reference
ULSyncResult class
The attributes of the ULSyncResult object store the results of the last
synchronization.
Properties
The following are properties of ULSyncResult:
Prototype Description
155
ULSyncState enumeration
Constant Value
ulSyncStateStarting 0
ulSyncStateConnecting 1
ulSyncStateSendingHeader 2
ulSyncStateSendingTable 3
ulSyncStateSendingData 4
ulSyncStateFinishingUpload 5
ulSyncStateReceivingUploadAck 6
ulSyncStateReceivingTable 7
ulSyncStateReceivingData 8
ulSyncStateCommittingDownload 9
ulSyncStateSendingDownloadAck 10
ulSyncStateDisconnecting 11
ulSyncStateDone 12
ulSyncStateError 13
ulSyncStateCancelled 99
156
Chapter 6. UltraLite ActiveX API Reference
ULTable class
The ULTable class is used to store, remove, update, and read data from a
table.
Before you can work with table data, you must call the Open method.
ULTable uses table modes for table operations:
Mode Description
Properties
Prototype Description
Close method
Prototype Close( )
Member of UltraliteActiveX.ULTable
157
Description Frees resources associated with the table. This method should be called after
all processing involving the table is complete.
Delete method
Prototype Delete( )
Member of UltraliteActiveX.ULTable
Description Deletes the current row from the table.
DeleteAllRows method
Prototype DeleteAllRows( )
Member of UltraliteActiveX.ULTable
Description Deletes all rows in the table.
In some applications, it can be useful to delete all rows from tables before
downloading a new set of data into the table. Rows can be deleted from the
UltraLite database without being deleted from the consolidated database
using the ULConnection.StopSynchronizationDelete method or calling
Truncate instead of DeleteAllRows.
FindBegin method
Prototype FindBegin( )
Member of UltraliteActiveX.ULTable
Description Prepares a table for a find.
FindFirst method
Prototype FindFirst( [num_columns As Long = 32767] ) As Boolean
Member of UltraliteActiveX.ULTable
Description Move forwards through the table from the beginning, looking for a row that
exactly matches a value or set of values in the current index.
The current index is that used to specify the sort order of the table. It is
specified when your application calls the Open method. The default index is
the primary key.
To specify the value to search for, set the column value for each column in
the index. The cursor is left on the first row that exactly matches the index
value. On failure the cursor position is after the last row (EOF).
Note : Requires that FindBegin be called prior to using this method.
Parameters num_columns An optional parameter referring to the number of columns
to be used in the FindFirst. For example, if 2 is passed, the first two columns
158
Chapter 6. UltraLite ActiveX API Reference
are used for the FindFirst. If num_columns exceeds the number of columns
indexed, all columns are used in FindFirst.
Returns True if successful.
False if unsuccessful.
FindLast method
Prototype FindLast( [ num_columns As Long = 32767 ] ) As Boolean
Member of UltraliteActiveX.ULTable
Description Move backwards through the table from the end, looking for a row that
matches a value or set of values in the current index.
The current index is used to specify the sort order of the table. It is specified
when your application calls the Open method. The default index is the
primary key.
☞ For more information, see “Open method” on page 164.
To specify the value to search for, set the column value for each column in
the index for which you want to find the value. The cursor is left on the last
row found that exactly matches the index value. On failure the cursor
position is before the first row (BOF).
Note
Requires that FindBegin be called prior to using this method.
Parameters num_columns An optional parameter referring to the number of columns
to be used in the FindLast. For example, if 2 is passed, the first two columns
are used for the FindLast. If num_columns exceeds the number of columns
indexed, all columns are used in FindLast.
Returns True if successful.
False if unsuccessful.
FindNext method
Prototype FindNext( [ num_columns As Long = 32767 ] ) As Boolean
Member of UltraliteActiveX.ULTable
Description Move forwards through the table from the current position, looking for the
next row that exactly matches a value or set of values in the current index.
The current index is that used to specify the sort order of the table. It is
specified when your application calls the Open method. The default index is
the primary key.
☞ For more information, see “Open method” on page 164.
159
The cursor is left on the first row found that exactly matches the index value.
On failure, the cursor position is after the last row (EOF).
Note : Must be preceded by FindFirst or FindLast.
Parameters num_columns An optional parameter referring to the number of columns
to be used in the FindNext. For example, if 2 is passed, the first two columns
are used for the FindNext. If num_columns exceeds the number of columns
indexed, all columns are used in FindNext.
Returns True if successful.
False if unsuccessful (EOF).
FindPrevious method
Prototype FindPrevious( [ num_columns As Long = 32767 ] ) As Boolean
Member of UltraliteActiveX.ULTable
Description Move backwards through the table from the current position, looking for the
previous row that exactly matches a value or set of values in the current
index.
The current index is that used to specify the sort order of the table. It is
specified when your application calls the Open method. The default index is
the primary key.
☞ For more information, see “Open method” on page 164.
On failure it is positioned before the first row (BOF).
Parameters num_columns An optional parameter referring to the number of columns
to be used in the FindPrevious. For example, if 2 is passed, the first two
columns are used for the FindPrevious. If num_columns exceeds the number
of columns indexed, all columns are used in FindPrevious.
Returns True if successful.
False if unsuccessful (BOF).
Insert method
Prototype Insert( ) As Boolean
Member of UltraliteActiveX.ULTable
Description Inserts a row in the table with values specified in previous Set methods.
Must be preceded by InsertBegin. Set for each ULColumn object.
Returns True if successful.
False if unsuccessful (BOF).
160
Chapter 6. UltraLite ActiveX API Reference
InsertBegin method
Prototype InsertBegin( )
Member of UltraliteActiveX.ULTable
Description Prepares a table for inserting a new row, setting column values to their
defaults.
Examples In this example, InsertBegin sets insert mode to allow you to begin assigning
data values to CustomerTable columns.
’ eMbedded Visual Basic
CustomerTable.InsertBegin
CustomerTable.Columns("Fname").Value = fname
CustomerTable.Columns("Lname").Value = lname
If Len(city) > 0 Then
CustomerTable.Columns("City").Value = city
End If
If Len(phone) > 0 Then
CustomerTable.Columns("phone").Value = phone
End If
CustomerTable.Insert
// JScript
CustomerTable.InsertBegin();
CustomerTable.Columns("Fname").Value = fname;
CustomerTable.Columns("Lname").Value = lname;
If ( Len(city) > 0 ) {
CustomerTable.Columns("City").Value = city;
}
If ( Len(phone) > 0 ) {
CustomerTable.Columns("phone").Value = phone;
}
CustomerTable.Insert();
LookupBackward method
Prototype LookupBackward( [ num_columns As Long = 32767 ] ) As Boolean
Member of UltraliteActiveX.ULTable
Description Move backwards through the table starting from the end, looking for the first
row that matches or is less than a value or set of values in the current index.
The current index is that used to specify the sort order of the table. It is
specified when your application calls the Open method. The default index is
the primary key.
☞ For more information, see “Open method” on page 164.
To specify the value to search for, set the column value for each column in
161
the index. The cursor is left on the last row that matches or is less than the
index value. On failure (that is, if no row is less than the value being looked
for), the cursor position is before the first row (BOF).
Parameters num_columns An optional parameter referring to the number of columns.
Returns True if successful.
False if unsuccessful.
LookupBegin method
Prototype LookupBegin( )
Member of UltraliteActiveX.ULTable
Description Prepares a table for a lookup.
LookupForward method
Prototype LookupForward( [num_columns As Long = 32767 ] ) As Boolean
Member of UltraliteActiveX.ULTable
Description Move forward through the table starting from the beginning, looking for the
first row that matches or is greater than a value or set of values in the current
index.
The current index is that used to specify the sort order of the table. It is
specified when your application calls the Open method. The default index is
the primary key.
☞ For more information, see “Open method” on page 164.
To specify the value to search for, set the column value for each column in
the index. The cursor is left on the first row that matches or is greater than
the index value. On failure (that is, if no rows are greater than the value
being looked for), the cursor position is after the last row (EOF).
Parameters num_columns An optional parameter referring to the number of columns.
Returns True if successful.
False if unsuccessful.
MoveAfterLast method
Prototype MoveAfterLast( ) As Boolean
Member of UltraliteActiveX.ULTable
Description Moves to a position after the last row.
Returns True if successful.
162
Chapter 6. UltraLite ActiveX API Reference
MoveBeforeFirst method
Prototype MoveBeforeFirst( ) As Boolean
Member of UltraliteActiveX.ULTable
Description Moves to a position before the first row.
Returns True if successful.
False if the operation fails.
MoveFirst method
Prototype MoveFirst( ) As Boolean
Member of UltraliteActiveX.ULTable
Description Moves to the first row.
Returns True if successful.
False if there is no data in the table.
MoveLast method
Prototype MoveLast( ) As Boolean
Member of UltraliteActiveX.ULTable
Description Moves to the last row.
Returns True if successful.
False if there is no data in the table.
MoveNext method
Prototype MoveNext( ) As Boolean
Member of UltraliteActiveX.ULTable
Description Moves to the next row.
Returns True if successful.
False if there is no more data in the table. For example, MoveNext fails if
there are no more rows.
MovePrevious method
Prototype MovePrevious( ) As Boolean
Member of UltraliteActiveX.ULTable
Description Moves to the previous row.
163
Returns True if successful.
False if there is no more data in the table. For example, MovePrevious fails
if there are no rows.
MoveRelative method
Prototype MoveRelative( index As Long ) As Boolean
Member of UltraliteActiveX.ULTable
Description Moves a certain number of rows relative to the current row.
Parameters index The number of rows to move. The value can be positive, negative, or
zero. Zero is useful if you want to repopulate a row buffer.
Returns True if successful.
False if the move failed, as may happen, for example, if the cursor is
positioned beyond the first or last row.
Open method
Prototype Open(
[ index_id ], _)
Member of UltraliteActiveX.ULTable
Description Opens the table so it can be read or manipulated. By default, the rows are
ordered by primary key. By supplying an index , the rows can be ordered in
other ways.
The cursor is positioned before the first row in the table.
Parameters indexID An optional parameter referring to the ID of the index.
Truncate method
Prototype Truncate( )
Member of UltraliteActiveX.ULTable
Description Removes all data from this table. The changes are not synchronized, so that
on synchronization, it does not affect the data in the consolidated database.
☞ For more information, see “StopSynchronizationDelete method” on
page 115.
Update method
Prototype Update( )
Member of UltraliteActiveX.ULTable
Description Updates a row in the table with values specified in ULColumn methods.
164
Chapter 6. UltraLite ActiveX API Reference
UpdateBegin method
Prototype UpdateBegin( )
Member of UltraliteActiveX.ULTable
Description Prepares a table for modifying the contents of the current row.
Example
’ eMbedded Visual Basic
Table.UpdateBegin
Table.Columns( "ColName" ).Value = "New Value"
Table.Update
// JScript
Table.UpdateBegin();
Table.Columns("ColName").Values = "NewValue";
Table.Update();
165
ULTableSchema class
The ULTableSchema object allows you to obtain the attributes of a table.
Properties
The ULTableSchema represents metadata about the table. The following are
properties of the ULTableSchema class:
Prototype Description
InPublication method
Prototype InPublication( publicationName ) As Boolean
Member of UltraliteActiveX.ULTableSchema
Description Indicates whether this table is part of the specified publication.
Parameters publicationName The name of the publication you are checking.
Returns True if the table is part of the publication.
False if the table is not part of the publication.
166
Index
167
Index
168
Index
169
Index
170
Index
171
Index
about 74 about 88
PrepareStatement method RowCount property (ULTable class)
(ULConnection class) UltraLite ActiveX 157
UltraLite ActiveX 114 rows
preparing to work with ActiveX accessing current row 82
about 60
UltraLite ActiveX 60 S
PrimaryKey property (ULIndexSchema
samples
class)
UltraLite 41
UltraLite ActiveX 131
Scale property (ULColumnSchema class)
PrimaryKey property (ULTableSchema
UltraLite ActiveX 110
class)
schema
UltraLite ActiveX 166
accessing 89
projects
schema files
creating UltraLite for MobileVB
about 63
projects 27
creating 64
PublicationCount property
Schema painter
(ULDatabaseSchema class)
starting 64
UltraLite ActiveX 128
Schema property (ULColumn class)
PublicationMask property
UltraLite ActiveX 105
(ULSyncParms class)
Schema property (ULConnection class)
UltraLite ActiveX 153
UltraLite ActiveX 111
publications
Schema property (ULTable class)
accessing schema information 89
UltraLite ActiveX 157
scrolling
R through rows 81
RealValue property (ULColumn class) searching
UltraLite ActiveX 105 rows 83
ReferencedIndexName property SELECT
(ULIndexSchema class) about 77
UltraLite ActiveX 131 SendColumnNames property
ReferencedTableName property (ULSyncParms class)
(ULIndexSchema class) UltraLite ActiveX 153
UltraLite ActiveX 131 SendDownloadAck property
ResetLastDownloadTime method (ULSyncParms class)
(ULConnection class) UltraLite ActiveX 153
UltraLite ActiveX 115 SetByteChunk method (ULColumn class)
RevokeConnectFrom method UltraLite ActiveX 108
(ULConnection class) SetNullParameter method
UltraLite ActiveX 115 (ULPreparedStatement class)
revokeConnectionFrom method UltraLite ActiveX 134
introduction 93 SetParameter method
Rollback method (ULPreparedStatement class)
about 88 UltraLite ActiveX 134
Rollback method (ULConnection class) SetToDefault method (ULColumn class)
UltraLite ActiveX 115 UltraLite ActiveX 109
rollbacks
172
Index
173
Index
174
Index
175
Index
W
Windows CE
supported versions 2
176