IBM Universe Uonet
IBM Universe Uonet
fm
February 22, 2008 2:07 pm
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta
IBM
Version 10.2
February, 2008
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Front.fm
February 22, 2008 2:07 pm
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
IBM Corporation
555 Bailey Avenue
San Jose, CA 95141
© Copyright International Business Machines Corporation 2006, 2008. All rights reserved.
AIX, DB2, DB2 Universal Database, Distributed Relational Database Architecture, NUMA-Q, OS/2, OS/390, and
OS/400, IBM Informix®, C-ISAM®, Foundation.2000 ™, IBM Informix® 4GL, IBM Informix® DataBlade® module,
Client SDK™, Cloudscape™, Cloudsync™, IBM Informix® Connect, IBM Informix® Driver for JDBC, Dynamic
Connect™, IBM Informix® Dynamic Scalable Architecture™ (DSA), IBM Informix® Dynamic Server™, IBM
Informix® Enterprise Gateway Manager (Enterprise Gateway Manager), IBM Informix® Extended Parallel Server™,
i.Financial Services™, J/Foundation™, MaxConnect™, Object Translator™, Red Brick® Decision Server™, IBM
Informix® SE, IBM Informix® SQL, InformiXML™, RedBack®, SystemBuilder™, U2™, UniData®, UniVerse®,
wIntegrate® are trademarks or registered trademarks of International Business Machines Corporation.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the
United States and other countries.
Microsoft .NET, Windows, Windows NT, and Excel are either registered trademarks or trademarks of Microsoft
Corporation in the United States and/or other countries.
UNIX is a registered trademark in the United States and other countries licensed exclusively through X/Open Company
Limited.
Other company, product, and service names used in this publication may be trademarks or service marks of others.
Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Table of Contents
Preface
Organization of This Manual . . . . . . . . . . . . . . . viii
Documentation Conventions . . . . . . . . . . . . . . . ix
Help . . . . . . . . . . . . . . . . . . . . . . . ix
API Documentation . . . . . . . . . . . . . . . . . . x
Additional References . . . . . . . . . . . . . . . . . xi
Chapter 1 Introduction
About UniObjects for .NET . . . . . . . . . . . . . . . . 1-3
About Microsoft .NET . . . . . . . . . . . . . . . . . 1-4
What Is the .NET Framework? . . . . . . . . . . . . . 1-4
Architecture of UniObjects for .NET . . . . . . . . . . . . . 1-8
Features of UniObjects for .NET . . . . . . . . . . . . . . 1-10
NLS Support . . . . . . . . . . . . . . . . . . . 1-10
Tracing and Logging . . . . . . . . . . . . . . . . 1-11
UniDynArray and UniDataSet . . . . . . . . . . . . . 1-12
UniFile Read/Write Methods . . . . . . . . . . . . . . 1-12
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Table of Contents v
February 22, 2008 2:07 pm
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Index
Preface
This manual describes UniObjects for .NET, an interface to UniVerse and UniData
databases from .NET.
If you are new to UniVerse or UniData, you should read at least The Database
Environment in Chapter 2, “Using UniObjects for .NET.”
If you are new to .NET, read one or more of the books listed in “Additional
References” on page xi.
Chapter 2, “Using UniObjects for .NET,” outlines the database environment and
explains how to use UniObjects for .NET to connect to the database, open files, and
access records.
Chapter 3, “A Tour of the Objects,” describes the classes of UniObjects for .NET,
detailing their associated constructors, properties, and methods.
Chapter 5, “Using Code Samples,” provides code samples for simple software appli-
cations to help you get up to speed quickly with UniObjects for .NET.
Documentation Conventions
This manual uses the following conventions:
Convention Usage
Help
You can get Help about UniObjects for .NET. In Windows Explorer, find and open
the following file:
<Drive>:\IBM\UNIDK\UONET\doc\uodotnet.chm
ix
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Preface.fm
2/22/08
API Documentation
The following manuals document application programming interfaces (APIs) used
for developing client applications that connect to UniVerse and UniData servers.
Administrative Supplement for Client APIs: Introduces IBM’s seven common APIs,
and provides important information that developers using any of the common APIs
will need. It includes information about the UniRPC, the UCI Config Editor, the
ud_database file, and device licensing.
UCI Developer’s Guide: Describes how to use UCI (Uni Call Interface), an interface
to UniVerse and UniData databases from C-based client programs. UCI uses ODBC-
like function calls to execute SQL statements on local or remote UniVerse and
UniData servers. This book is for experienced SQL programmers.
IBM JDBC Driver for UniData and UniVerse: Describes UniJDBC, an interface to
UniData and UniVerse databases from JDBC applications. This book is for experi-
enced programmers and application developers who are familiar with UniData and
UniVerse, Java, JDBC, and who want to write JDBC applications that access these
databases.
InterCall Developer’s Guide: Describes how to use the InterCall API to access data
on UniVerse and UniData systems from external programs. This book is for experi-
enced programmers who are familiar with UniVerse or UniData.
UniObjects for Java Developer’s Guide: Describes UniObjects for Java, an interface
to UniVerse and UniData systems from Java. This book is for experienced
programmers and application developers who are familiar with UniVerse or UniData,
and with Java, and who want to write Java programs that access these databases.
Additional References
Either of the following books may be useful if you are new to programming with
.NET:
Visual Basic .NET Developer’s Guide to ASP.NET, XML and ADO.NET, by Jeffrey
P. McManus and Chris Kinsman, February 2002, ISBN 0-672-32 1319, Addison
Wesley Publication.
xi
1Administering UniData on Windows NT or Windows 2000
0
Chapter
Introduction
1
About UniObjects for .NET . . . . . . . . . . . . . . . 1-3
About Microsoft .NET . . . . . . . . . . . . . . . . . 1-4
What Is the .NET Framework? . . . . . . . . . . . . . 1-4
Architecture of UniObjects for .NET . . . . . . . . . . . . 1-8
Features of UniObjects for .NET . . . . . . . . . . . . . . 1-10
NLS Support. . . . . . . . . . . . . . . . . . . 1-10
Tracing and Logging . . . . . . . . . . . . . . . . 1-11
UniDynArray and UniDataSet . . . . . . . . . . . . . 1-12
UniFile Read/Write Methods . . . . . . . . . . . . . 1-12
This chapter introduces the UniObjects for .NET interface. It first gives you a basic
understanding of Microsoft .NET and the .NET Framework. It then describes the
architecture of UniObjects for .NET. Finally, it provides an overview of the features
of UniObjects for .NET.
1-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch1.fm
2/22/08
Software developers can use the UniObjects for .NET API and any CLR language
(such as C#, J#, VB.NET, or C++ .NET) to create the following types of application
and services:
Console applications
Windows applications
ASP.NET Web applications
XML Web services
Smart Client applications for desktop and pocket PCs
You will need to know more about Microsoft .NET and the .NET Framework before
we go on to discuss its use with UniObjects. The next section introduces you to the
concepts and components of Microsoft .NET.
1-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch1.fm
2/22/08
The following illustration shows the .NET Framework in the context of the Windows
environment. The parts of the .NET Framework are shown within the bracket marked
.NET Framework.
VB.NET C# J# …
ASP.NET Windows
Web Forms XML Web Services
Forms
With the .NET Framework, it is easier than ever to build, deploy, and administer
secure, robust, high-performing software applications. The .NET Framework:
language integration
security enforcement
memory, process, and thread management
In addition, CLR has a role at development time when features such as life-cycle
management, strong type naming, cross-language exception handling, and dynamic
binding reduce the amount of code that the software developer must write to turn
business logic into a reusable component.
Managed code
This type of code is executed and managed by the .NET Framework’s Common
Language Runtime. Managed code must supply the instruction set necessary for the
CLR to provide services such as memory management, cross-language integration,
code access security, and automatic lifetime control of objects. All code that has been
compiled in Microsoft Intermediate Language executes as managed code.
Unmanaged code
This type of code is executed by the operating system, outside the .NET Framework’s
Common Language Runtime. Unmanaged code must provide its own memory
management, type checking, and security support, unlike managed code, which
receives these services from the Common Language Runtime.
Class libraries
The .NET Framework uses a number of class libraries, listed below. Together, the
class libraries provide a common, consistent development interface across all
languages supported by the .NET Framework.
1-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch1.fm
2/22/08
UniObjects for .NET is the data access model for .NET applications that connect to
the UniData and UniVerse databases. It contains a collection of classes that allow you
to connect to the UniData and UniVerse databases, execute commands, and read and
write results:
1-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch1.fm
2/22/08
Since UniObjects for .NET is written purely in C#, it is managed code; it does not use
any functions outside of the .NET Framework CLR. The UO.NET code complies
with the .NET Framework standard and it follows C# conventions for names,
comments, and standards.
While the two interfaces are very similar, UniObjects for .NET offers several
improvements over UniObjects for Java. This section describes only those features
of UniObjects for .NET that are not found in UniObjects for Java:
NLS Support
Tracing and Logging
UniDynArray and UniDataSet
UniFile Read/Write Methods
NLS Support
UniObjects for .NET supports the Encoding class of the .NET Framework class
library through its UniSession class property called UOEncoding.
The Encoding class provides methods to convert arrays and strings of UniCode
characters to and from arrays of bytes encoded for a target page. An application can
use the properties of the Encoding class such as ASCII, Default, Unicode, UTF7, and
UTF8.
For example:
UniSession m_us=UniObjects(“xxx”, “yyy”, “localhost”, “demo”, “udcs”);
Encoding en=Encoding.UTF8;
m_us.UOEncoding=en;
1-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch1.fm
2/22/08
1(error)
2(warning)
3(info)
4(verbose)
A UniObjects for .NET application can select one of these four levels and specify a
storage destination for the output of tracing and logging. If no destination is given,
the default output file UniTraceLog.txt is generated in the system’s temporary folder.
By default, tracing and logging are turned off in UniObjects for .NET. Tracing can be
turned on using the application configuration file. For example:
<system.diagnostics>
<switches>
</listeners>
</trace>
</system.diagnostics>
In the above example., tracing is turned on and it is set to the 1(error) level. The log
file name is c:\temp\myListener.log.
UniDynArray stores data internally in byte arrays, so it deals with binary data only,
as does the server. One difference from its implementation in UniObjects for Java is
that the ToString() method and StringValue property return the UniCode string after
converting the binary data based on the associated session’s encoding. Other changes
to UniDynArray from UOJ include one constructor that takes binary data and one
output method that returns a byte array.
UOJ UniFile read and write have many overloading methods, which can be
confusing. This led us to introduce different names for different operations in
UniObjects for .NET UniFile. For example, to read a single field from a file, you can
use UniFile.ReadField() or UniFile.ReadNamedField(); to read multiple
fields, you can use UniFile.ReadFields() or
UniFile.ReadNamedFields().
Another noticeable difference in the UniObjects for .NET UniFile Read and Write
methods is that they take parameters of specific types like int, string, and string[],
whereas in UOJ they can take parameters of a general object type. Strong typing
methods are better because their early binding requirements can catch application
errors during compilation rather than at run time.
1-12
1Administering UniData on Windows NT or Windows 2000
0
Chapter
This chapter explains how to use UniVerse or UniData in a .NET application. The
topics covered include:
If you are new to Microsoft .NET, you should read one of the books listed under
Additional References in the “Preface” before you start this chapter.
2-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
Note: UniVerse has several account flavors. The following sections describe the
UniVerse IDEAL flavor, which is recommended for use with UniObjects. UniData
uses ECLTYPE and BASICTYPE to specify account flavors. See the Using UniData
manual for information about UniData flavors.
Each database file comprises a data file containing data records, and a file dictionary
that defines the structure of the data records and how to display them. Each record in
a file is uniquely identified by a record ID, which is stored separately from the data
to which it refers.
The VOC (vocabulary) file in a database account contains a record for every file used
in the database. This record provides a cross-reference between the file name, which
is the record ID, and the path of the file stored in field 2 of the record.
Data Structure
In an application, each file holds one type of record. For example, a file called
CUSTOMER might hold one record for each customer, whereas another file called
ORDERS might hold one record for each order placed by a customer. The records
and the fields they contain are not fixed in size, and the file itself can grow or shrink
according to the amount of data it holds.
Data is stored in fields in a record. For example, a record in the CUSTOMER file
might have fields containing the name, address, and telephone number of a customer.
A field can hold more than one value, for example, the separate elements of an
address can be stored as multivalues of one field rather than as separate fields in the
record. A field in one record can contain a cross-reference to data held in another file.
For example, to link customers with their orders, records in the CUSTOMER file
might have a multivalued field containing a list of the corresponding record IDs of
their orders in the ORDERS file.
File Dictionaries
The file dictionary holds information about the structure of data records and their
relationships to other files. In a record, each field is identified by a number, and the
dictionary acts as a cross-reference between that number and the name of the field.
For example, the customer’s phone number might be held in a field called
CUST.PHONE, which is field 3 in the record.
The file dictionary also defines how to format and display the data in the field for
output; for example, the heading and the width of the column used in a report. All
data is stored as character strings. Some data, such as monetary amounts and dates,
is stored in a compact, internal format. For these fields, the dictionary holds a
conversion code, which specifies a conversion to apply before displaying the data.
I-descriptors can perform calculations on data stored in one record, or retrieve data
from other files. For example, records in the CUSTOMER file have a field that lists
related record IDs in the ORDERS file. The CUSTOMER file dictionary could
contain I-descriptors that use the TRANS function to retrieve fields from those
related records.
2-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
Locks
When a program makes changes to the database, it sets a lock on each record involved
in the update, ensuring that no other user or process can modify the record until the
lock is released. Locks and locking strategy are described in “Record Locks” on
page 2-18.
Data Retrieval
UniVerse contains several utilities to use with the database, including:
The database also has many commands and keywords for administering and
maintaining the database. All these utilities and commands can be accessed by a
program through UniObjects. For more information, see “Using Database
Commands” on page 2-25.
UniObjects Concepts
If you already know UniVerse or UniData, you will find that UniObjects uses some
different terms to define familiar database features. This section defines those terms
and shows how they map to the database.
Objects
An object is an instance of a class. All objects of a class share characteristics. The
objects you can use with UniObjects for .NET are shown in the following table. The
five most commonly used classes are listed first in the order in which you are most
likely to use them in an application. The remaining classes are organized in alpha-
betical order.
Object Description
2-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
Object Description
Methods
Methods are procedures used with a particular object. Many of the methods used in
UniObjects for .NET are equivalent to UniObjects methods and properties, and to
BASIC statements and functions. For example, the ClearFile() method is equiv-
alent to the UniObjects ClearFile method and the BASIC CLEARFILE statement.
Properties
Properties represent the internal state of any given object. In UniObjects for .NET,
you use a .NET property declaration. Properties are an extension of fields and are
accessed using the same syntax. Unlike fields, properties have accessors that read,
write, or compute their values. For example:
//A read-write instance property
public string fileName
get
{
return name;
}
set
{
name=value;
}
2-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
Once the session is active, you can use it to create other objects. For example, if you
want to open a file, execute a database command, or run a subroutine on the server,
you start the operation using the methods provided by the UniSession object.
The UniSession object must exist for as long as your application needs access to
the server. When a UniSession object is no longer active, this closes the connection
with the database server. This means that although the objects created through a
UniSession object are still available, you may not be able to use them. For
example, if you have a UniFile object, you can access the last record read from the
file, but you cannot read another record.
Data Encryption
Data encryption is a facility in which data transmissions between the client and server
is modified to prevent unsecure parties from intercepting sensitive data. UniObjects
for .NET provides the facility to use encryption at the session, object, and operation
levels.
Object Method
UniCommand CreateUniCommand()
UniDictionary CreateUniDictionary()
UniDynArray CreateUniDynArray()
UniObjects for .NET Objects and Methods
Object Method
UniFile CreateUniFile()
UniNLSLocale CreateNLSLocale()
UniNLSMap CreateNLSMap()
UniSelectList CreateUniSelectList()
UniSequentialFile CreateSequentialFile()
UniSubroutine CreateUniSubroutine()
UniTransaction CreateUniTransaction()
UniObjects for .NET Objects and Methods (Continued)
You can use this returned value by adding a paragraph entry to the VOC file. For
example:
PA
IF @TTY = 'uvcs' THEN GO END:
START.APP
END:
Using Files
Before you can use a database file, you must open the file using the
CreateUniFile() method of the UniSession object as follows:
UniFile custfile = uSession.CreateUniFile("CUST");
2-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
To write data back to the file, call the Write() method of the UniFile object. For
example:
custFile.Write();
dynArray is the object variable, method is the method you want to use, and field,
value, and subvalue are integers representing the respective field, value, or
subvalue you want to access. If no field is given, the operation occurs over the entire
array.
For example, to find what is the third value in a dynamic array, write:
UniDynArray thirdField = origArray.Extract( 3 );
This extracts field 3 from the origArray and returns the data into the object
thirdField.
This extracts the second value from the third field and returns the object into
thirdFieldSecondValue.
To modify data in the object, do the same thing. For example, to change the second
value of the third field, write:
origArray.Replace( 3, 2, "NewData" );
2-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
And finally, to delete the fourth subvalue of the first value of field 3:
origArray.Delete( 3, 1, 4 );
You can also use the other methods in the same way.
Data Conversion
When you read and write an entire record, your program must handle conversion of
data to and from its internal storage format. You do this using the Iconv() (input
convert) and Oconv() (output convert) methods of the UniSession object.
For example:
UniDynArray dateBox = uSession.Oconv(x,"D");
In most cases the position of the field in the record and the conversion code to apply
must be written into your program. This means that your program may need to
change if the structure of the record changes.
As an alternative, you can read or write to a named field rather than to the entire
record, and let UniObjects consult the file dictionary and perform any data
conversion for you. You do this using the ReadNamedField() and
WriteNamedField() methods.1
The ReadNamedField() method of the UniFile object lets a program request data
in its converted form from a field specified by name. ReadNamedField() can also
evaluate I-descriptors. For example, the code to read the LAST.ORDER.DATE field
might look like this:
UniDynArray rec = custFile.ReadNamedField('LAST.ORDER.DATE');
The WriteNamedField() method does the converse, that is, it takes a data value,
applies an input conversion to it, then writes it to the appropriate location in the
record. It does not support I-descriptors.
2-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
Error Handling
UniObjects for .NET separates the code that handles error exceptions from the
normal code flow. An exceptional condition is said to throw an exception that must
be caught. Whenever an error occurs in one of the API libraries, the method encoun-
tering the error throws a particular exception, which the programmer must then catch
and handle appropriately. This is done using .NET try/catch blocks. For example:
try
{
result = uFile.Read(recordToBeRead);
result2 = uFile.Read(nextRecordToBeRead);
}
catch(Exception e)
{
processError(e);
}
This ensures that normal operations are handled in one section, and exceptional
conditions are handled in another section.
Many classes support a status property (for example, FileStatus), which enables
the developer to get additional information about certain operations.
UniObjects for .NET does not have a direct equivalent to the THEN and ELSE
clauses that a BASIC programmer uses to specify different actions depending on the
success of an operation. Instead, all database objects throw a UniException object,
which is set by various methods. If the method does not finish successfully, the
UniException object indicates an error. For a list of error codes, see Appendix A,
“Error Codes and Replace Tokens.”
For example, if you call the Read() method of a UniFile object, the operation fails
if the record does not exist. In this case, the UniFileException object indicates
the record was not found.
For examples of error handling, see the entry for the UniFile object in Chapter 3,
“A Tour of the Objects.”
Record Locks
Note: BASIC programmers should read this section carefully. Locking is handled
differently in UniObjects to make coding easier in the event-driven environment of a
client application.
UniVerse and UniData have a system of locks to prevent potential problems when
several users try to access the same data at the same time. The three types of lock you
can use in programs are task locks, file locks, and record locks. This section discusses
only record locks, which are used most often. For information on task locks and file
locks, refer to the descriptions of the CreateTaskLock() and
ReleaseTaskLock() methods of the UniSession object, and to the
LockFile() and UnlockFile() methods of the UniFile object, in Chapter 3, “A
Tour of the Objects.” See also the UniVerse System Description for more information
on record and file locks.
Exclusive update locks (READU locks), which prevent other users from
reading or writing to the record
Shared read locks (READL locks), which allow other users to read the
record but not to update it
2-17
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
You can set these properties for each file, or you can use the defaults associated with
the UniSession object. These defaults are specified using the
BlockingStrategy, LockStrategy, and ReleaseStrategy properties of the
UniSession object. In either case the properties remain set for all subsequent reads
on that file during the session; you do not need to set them again. For examples, see
the entries for the UniFile and UniSession objects in Chapter 3, “A Tour of the
Objects.”
Select Lists
In UniVerse and UniData you can retrieve a specified set of record IDs, saving them
as an active select list. You can either use the active select list immediately in a
program or command, or give it a name and save it for future use. A UniVerse session
can have up to 11 select lists active at the same time, numbered from 0 through 10. A
UniData session can have up to 10 active select lists, numbered from 0 through 9.
If you just want to read part of a list, you can discard the unwanted part by calling the
ClearList() method.
For more information and examples, see the entry for the UniSelectList object in
Chapter 3, “A Tour of the Objects.”
2-19
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
Using a Dictionary
For most application programs it is economical to build a record’s structure and field
types into the program. This avoids having to look up the format of the record in the
file dictionary. If you want your program to process different types of records, you
will need to look in the file dictionary to see how the records are structured. In a
UniObjects for .NET application, you do this through the
CreateUniDictionary() method of the UniSession object. This returns a
UniDictionary object, which has methods for reading and writing particular fields
from the dictionary. These methods are:
For more information about these methods, see the entry for the UniDictionary
object in Chapter 3, “A Tour of the Objects.”
Record ID Filename
For small text files, you can open the type 1 or type 19 file with the Open() method
and then read an entire text file with the Read() method. See “Using Files” on
page 2-12.
Read and write lines of text with the ReadLine() and WriteLine()
methods
Read and write binary data with the ReadBlk() and WriteBlk() methods
Change the position of the file pointer with the FileSeek() method
Truncate an existing file with the WriteEOF() method
For more information, see the entry for the UniSequentialFile object in Chapter
3, “A Tour of the Objects.”
2-21
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
You can issue only one command at a time. You use the CreateUniCommand()
method of the UniSession object to create a UniCommand object. For example:
UniCommand com1 = uSession.CreateUniCommand()
You specify the command that you want to execute using the command property, and
then execute it by calling the Execute() method. For example:
com1.command="some command";
com1.Execute();
You can get the result of a command using the CommandStatus property and
Response property as follows:
To use the client and server efficiently, you must know which operations need to
communicate with the server and when those operations take place. If necessary, you
can then change the design of the application to reduce the interaction with the server.
The following sections describe some ideas for using the client and server
economically.
Note: A server subroutine must be cataloged before you can call it from UniObjects.
For more information about cataloging subroutines on UniVerse systems, see the
entry for the CATALOG command in UniVerse User Reference, and the discussion of
subroutines in UniVerse BASIC. For information about cataloging UniData subrou-
tines, see UniData Commands Reference and Administering UniData.
Your program can call a cataloged subroutine via the UniSubroutine object, which
you get using the CreateUniSubroutine() method of the UniSession object.
For example:
UniSubroutine getOrderData = uSession.CreateUniSubroutine()
("*GET.ORDER.DATA", 4);
2-23
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
Some commands can increase network traffic because they generate prompts or
messages that your program must then handle. If your program cannot cope with an
unexpected request for input from a command, it hangs, with no indication of what
went wrong. In particular, avoid using interactive commands such as CREATE.FILE
or REFORMAT which have many possible prompts and error conditions. (In most
cases it should not be necessary to create or reformat files as part of your application.)
Task Locks
You can protect a process running on the server from interruption by other users or
programs by setting a task lock. UniVerse and UniData have 64 task locks you can
assign to events or processes. For example, if your application uses a resource such
as a printer, you can set a task lock to prevent another database user from accessing
the printer during your print run.
You set and release task locks with the SetTaskLock() and ReleaseTaskLock()
methods of the UniSession object. Task locks have no predefined meanings. You
must ensure that your application sets and releases task locks efficiently. You can use
the LIST.LOCKS command to check which locks are in use and which users hold
them.
Connection Pooling
UniData 7.1 and UniVerse 10.2 support connection pooling with UniObjects for Java
and UniObjects for .NET.
The term connection pooling refers to the technology that pools permanent connec-
tions to data sources for multiple threads to share. It improves application
performance by saving the overhead of making a fresh connection each time one is
required. Instead of physically terminating a connection when it is no longer needed,
connections are returned to the pool and an available connection is given to the next
thread with the same credentials.
You can activate connection pooling in your program, or activate it through a config-
uration file.
The size of the connection pool changes dynamically between the minimum and
maximum sizes you specify, depending on the system demands. When there are no
pooled connections available, UniData either creates another connection, if the
maximum connection pool size has not been reached, or keeps the thread waiting in
the queue until a pooled connection is released or the request times out. If a pooled
connection is idle for a specified time, it is disconnected.
License Considerations
The actual size of a connection pool depends on the pooling licenses available on the
server. For example, if you set a connection pool to a minimum size of 2 and a
maximum size of 100, and you have 16 licenses available, the maximum connection
pool size will be 16. If you only have 1 license available, UniData does not create the
connection pool at all, since the minimum size of 2 cannot be met.
2-25
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
Connection Allocation
Once UniData allocates a pooled connection to a thread, the connection remains
exclusively attached to that thread until it is explicitly freed by the thread.
UniData does not “clean up” the pooled connection before allocating it to a user
thread with the same credentials. For example, UDT.OPTIONS settings, unnamed
common, environment variables, and so forth remain from previous use.
If you do not specify the minimum and maximum number of connections, UniData
defaults to 1 for the minimum and 10 for the maximum.
UniObjects.OpenSession(server_name, logon_name,
password,account,service_name)
Parameter Description
service_name This parameter is optional. The name of the rpc service. If you do not
specify service_name, UniData defaults to defcs. If you do specify
service_name, the service name must exist in the unirpcservices file.
UniObjects.OpenSession Parameters
When you close a session using connection pooling, UniData does not close the
connection, it makes the connection available in the connection pool.
2-27
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
namespace CPTest
{
class CPTest
{
[STAThread]
static void Main(string[] args)
{
UniSession us1=null;
try
{
UniObjects.UOPooling = true;
UniObjects.MinPoolSize = 1;
UniObjects.MaxPoolSize = 10;
us1 =
UniObjects.OpenSession("localhost","username","password","demo","udcs");
UniCommand cmd = us1.CreateUniCommand();
cmd.Command="SSELECT STATES";
cmd.Execute();
string response_str = cmd.Response;
Console.WriteLine(" Response from UniCommand
:"+response_str);
UniSelectList sl = us1.CreateUniSelectList(0);
while (!sl.LastRecordRead)
{
string s = sl.Next();
if (s != "")
{
Console.WriteLine(" Record ID : "+s);
}
}
}
catch(Exception e)
{
if(us1 != null && us1.IsActive)
{
UniObjects.CloseSession(us1);
us1= null;
}
Console.WriteLine("");
Console.WriteLine(Thread.CurrentThread.Name +" :
Connection failed in Test Program : " + e.Message +e.StackTrace);
Console.WriteLine("========================================================
=======================");
Console.WriteLine("========================================================
====================");
}
finally
{
if(us1 != null && us1.IsActive)
{
Console.WriteLine("");
Console.WriteLine(Thread.CurrentThread.Name +" :
Connection Passed in Test Program");
Console.WriteLine("========================================================
====================");
Console.WriteLine("========================================================
====================");
UniObjects.CloseSession(us1);
}
}
}
}
}
2-29
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch2.fm
2/22/08
The following table describes the configuration parameters for connection pooling:
Parameter Description
ConnectionPoolingOn When this value is set to 1, the connection is drawn from the
appropriate pool, or, if necessary, created and added to the
appropriate pool. The default value is 0.
OpenSessionTimeOut How much time UniObjects for .NET waits before timing out to
get a session from the connection pool. Expressed in
milliseconds.
uoj.properties Parameters
Chapter
This chapter describes the classes used in UniObjects for .NET and details their
associated constructors, properties, and methods. The five most commonly used
classes are listed first in the order in which you are most likely to use them in an appli-
cation. The remaining classes are organized in alphabetical order
Object Description
UniFile Next, your program is likely to access a database file on the server
UniDictionary through a UniFile or UniDictionary object.
3-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
Object Description
Note that exception classes are not documented in this chapter. For information on
exception classes, please see UniObjects for .NET Help.
Code Examples
The following objects include a short program example that illustrates many of the
methods associated with the object: UniObjects, UniSession, UniFile,
UniDictionary, UniSequentialFile, UniDynArray, UniSelectList,
UniCommand, and UniSubroutine.
The names of the objects, constructors, properties, and methods used in UniObjects
for .NET are case-sensitive.
3-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
On UniData systems, ECLTYPE U is best. You may encounter variations with other
ECLTYPE or UDT.OPTIONS settings.
UniObjects Methods
The following table lists the UniObjects methods.
CloseSession() Dispose()
OpenSession() Equals()
GetHashCode()
GetType()
ToString()
UniObjects Methods
3-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
3-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
3-12
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
3-14
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
Public
Instance Public Instance Public Instance Protected Instance
Constructors Properties Methods Methods
3-16
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
3-18
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
3-20
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
UniTransaction Methods
The following table lists the UniTransaction methods.
Begin() Dispose()
Commit() Finalize()
Dispose() MemberwiseClone()
Equals()
GetHashCode()
GetLevel()
GetType()
IsActive()
Rollback()
ToString()
UniTransaction Methods
3-22
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
3-24
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
3-26
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch3.fm
2/22/08
UniRoot Class
The UniRoot class is an abstract class. All UniObjects for .NET classes are inherited
from the UniRoot class. Tracing functionality is implemented in this class.
UniRoot( )
This is the default constructor for the class. The constructor takes no arguments.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
UniObjects Class
The UniObjects class represents an open connection to the UniData or UniVerse
database. This class cannot be inherited.
After calling this method, the UniSession.IsActive property returns false, and
any operation performed on this session, other than OpenSession() or
CloseSession(), results in an error and throws an exception.
Note: Other objects created by or associated with the session are still available, but
using them may cause an error. For example, if you have a UniFile object created
by the UniSession object, you can access the last record that was read from the file,
but you cannot read another record.
string hostname is the name or network address of the instance of the UniData
or UniVerse database to which to connect.
string userid is the user’s login name on the UniData or UniVerse database.
string service is the type of UniData or UniVerse database account: udvs for
UniData or uvcs for UniVerse.
try
{
us =
UniObjects.OpenSession("localhost","xxx","yyy","demo","udcs");
UniCommand runCmd = uSession.CreateUniCommand( ) ;
runCmd.Command = "RUN BP FOO" ;
runCmd.Execute();
catch(Exception e)
{
Console.WriteLine(e.Message +e.StackTrace);
}
finally
{
if(us != null && us.IsActive)
{
UniObjects.CloseSession(us);
UniSession Class
The UniSession object defines and manages a database session on the server. It is
the central object for any database session, controlling access to all objects dependent
on it.
Token
Numbe
r Token Description
Data compression is done on packets whose data size exceeds the compression
threshold. 0 is the default, which means no compression is performed.
Compression and decompression of data is handled at the network comms level and
is not accessible to users.
Token
Numbe
r Token Description
If you set UV_ENCRYPT for a session, all data transferred between client and server
is encrypted.
Token
Numbe
r Token Description
Token
Numbe
r Token Description
Altering the lock strategy does not affect files or dictionaries that are already open.
Altering the release strategy does not affect files or dictionaries that are already
opened.
Token
Numbe
r Token Description
int is the timeout value in seconds. The default value is 300 seconds (5 minutes).
Note: If you enter a value that is too small, a running process may time out. If this
occurs, an error code is returned and the connection to the server is dropped.
Token
Numbe
r Token Description
0 UniObjectsTokens.NETWORK_DEFAULT TCP/IP
Transport Tokens
Note: With TCP/IP connections, you must enter security information to connect to the
server, for example, user name and password.
string pRecordID is a record in the file. If the record does not exist and if
pCreateFlag is true, this method creates a record.
bool pCreateFlag is a flag specifying that the record should or should not be
created if it does not exist. If pCreateFlag is true, this method creates a record.
Value Description
This example opens the TEST2 program file for sequential processing:
UniSequentialFile uSeq = uSession.CreateSequentialFile("BP",
"TEST2", false);
This method corresponds to the database CREATE command (if the create flag is set
to true), the UniObjects OpenSequential method, and the BASIC OPENSEQ
statement.
int aLockNum is the number, 0 through 63, of the task lock to be set.
This method corresponds to the UniObjects SetTaskLock method and the BASIC
LOCK statement.
uSession.CreateTaskLock( 4 );
This method corresponds to the UniObjects OpenDictionary method and the BASIC
OPEN statement.
string is the string objects that represents the data you want to converted into a
dynamic array.
The returned UniDynArray object inherits the system delimiters associated with this
session.
This method corresponds to the UniObjects OpenFile method and the BASIC OPEN
statement.
int aSelectListNumber is the number, 0 through 10, of the select list to use.
int aNumArgs is the number of arguments that the server subroutine uses.
int aTokenVal is the token number for the @variable whose value is to be
retrieved, as follows:
Token
Number Token BASIC @Variables
1 UniObjectsTokens.AT_LOGNAME @LOGNAME
2 UniObjectsTokens.AT_PATH @PATH
3 UniObjectsTokens.AT_USERNO @USERNO
4 UniObjectsTokens.AT_WHO @WHO
5 UniObjectsTokens.AT_TRANSACTION @TRANSACTION
6 UniObjectsTokens.AT_DATA_PENDING @DATA.PENDING
7 UniObjectsTokens.AT_USER_RETURN_CODE @USER.RETURN.CODE
8 UniObjectsTokens.AT_SYSTEM_RETURN_CODE @SYSTEM.RETURN.CODE
9 UniObjectsTokens.AT_NULL_STR @NULL.STR
10 UniObjectsTokens.AT_SCHEMA @SCHEMA
@variable Tokens
int aMarkChar is the token number for the system delimiter, as follows.
Token
Number Token for System Delimiter Description
This method corresponds to the UniObjects FM, IM, SQLNULL, SVM, TM, and
VM properties.
The Iconv() method sets the UniSession object’s status to one of the following
values:
Value Description
This method corresponds to the UniObjects Iconv method and the BASIC ICONV
function.
try{
UniString iDate = uSession.Iconv( "12 Oct 96", "D2/" );
} catch (UniSessionException e )
{ ... deal with error...
}
Value Description
Value Description
This method corresponds to the UniObjects Oconv method and the BASIC OCONV
function.
try{
UniString oDate = uSession.Oconv( iDate, "D2/" );
} catch ( UniSessionException e )
{ ... deal with exception
}
int pLockNum is the number, 0 through 63, of the task lock to release.
int aTokenVal is the token number for the @variable to be set. This method
applies to the following @variable only:
Token
Numbe
r Token Description
7 UniObjectsTokens.AT_USER_RETURN_CODE @USER.RETURN.CODE
@variable Tokens
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
try
{
us =
UniObjects.OpenSession("localhost","xxx","yyy","demo","udcs");
UniCommand runCmd = uSession.CreateUniCommand( ) ;
runCmd.Command = "RUN BP FOO" ;
runCmd.Execute();
catch(Exception e)
{
Console.WriteLine(e.Message +e.StackTrace);
}
finally
{
if(us != null && us.IsActive)
{
UniObjects.CloseSession(us);
UniFile Class
The UniFile class defines and manages a data file on the server. You define the
UniFile object through the UniSession.CreateUniFile() method. For more
information about creating and using a UniFile object, see Using Files in Chapter
2, “Using UniObjects for .NET.”
Token
Numbe
r Token Description
For example:
UniSession us=null;
try
{
us =
UniObjects.OpenSession("localhost","xxx","yyy","demo","udcs");
UniFile fl = us.CreateUniFile("CUSTOMER");
If ( fl.IsFileOpen )
{
Console.WriteLine(“Do Something”);
}
catch(Exception e)
{
Console.WriteLine(e.Message +e.StackTrace);
}
finally
{
if(us != null && us.IsActive)
{
UniObjects.CloseSession(us);
This property also sets the data portion of the record, primarily to be used for
subsequent Write methods.
Token
Numbe
r Token Description
Token
Numbe
r Token Description
Token
Numbe
r Token Description
This method corresponds to the UniObjects ClearFile method and the BASIC
CLEARFILE statement.
This method corresponds to the UniObjects CloseFile method and the BASIC
CLOSE statement.
If you do not specify a record, the value set by the RecordID property is used.
uFile.DeleteRecord(rec);
This method corresponds to the UniObjects DeleteRecord method and the BASIC
DELETE and DELETEU statements.
string akNameObj is the field name of the secondary index whose information
you want.
For D-type indexes: field 1 contains D as the first character and field 2
contains the location number of the indexed field.
For I-type indexes: field 1 contains I as the first character, field 2 contains
the I-type expression, and the compiled I-type code occupies fields 19
onward.
If akNameObj is an empty string, a list of available secondary key indexes on the file
returns as a dynamic array of fields.
This method corresponds to the UniObjects GetAkInfo method and the BASIC
INDICES function.
string aRecordID is the record ID of the record supplied as data to the Itype
facility.
This method corresponds to the UniObjects IType method and the BASIC ITYPE
function.
This method corresponds to the UniObjects LockFile method and the BASIC
FILELOCK statement.
int aLockFlag is the token number for the lock flag value, as follows:
Token
Numbe
r Token Description
If you do not specify a record ID or dataset, the record is the one set previously by
the RecordID property.
Note: You may need to explicitly unlock the record using the UnlockRecord()
method, depending upon the release strategy value.
This method corresponds to the UniObjects LockRecord method and the BASIC
RECORDLOCKL and RECORDLOCKU statements.
UniDynArray ar = fl.Read(“54637”);
This method corresponds to the UniObjects Read method and the BASIC READ,
READL, and READU statements.
int aFieldNumber is the number of the field to read. Specify field 0 (the
record ID) to check if a record exists.
string aRecordID is the ID of the record whose field value you want to read. If
you do not specify aRecordID, the record ID is the one set previously by the
RecordID property.
This method corresponds to the UniObjects ReadField method and the BASIC
READV, READVL, and READVU statements.
UniFile fl = us.CreateUniFile("CUSTOMER");
UniDynArray ar = fl.ReadField(“2”,3);
string aRecordID is the ID of the record whose field value is to be read. If you
do not specify aRecordID, the record ID is the one set previously by the RecordID
property.
UniDynArray ar = fl.ReadFields(“2”,parr);
string aFieldName is the name of the field to be read. The field must be defined
by a D-descriptor or an I-descriptor in the file dictionary.
string aRecordID is the ID of the record containing the field to be read. If you do
not specify aRecordID, the record ID is the one set previously by the RecordID
property.
Note: This method needs to read the file dictionary in order to determine the location
of the field. This can affect the performance of your application. If performance is an
issue, use the ReadField() method. For more information about using the
ReadNamedField() method, see Data Conversion in Chapter 2, “Using
UniObjects for .NET.”
If ReadNamedField() returns the error UVE_RNF (record not found), the missing
record can be either the data record whose field value you want to read or the
dictionary record defining the field.
UniDynArray ar = fl.ReadNamedField(“2”,”FNAME”);
string[] pFieldNames is the name of the field to be read. The field must be
defined by a D-descriptor or an I-descriptor in the file dictionary.
string pRecordID is the ID of the record containing the field to be read. If you do
not specify aRecordID, the record ID is the one set previously by the RecordID
property.
Note: This method needs to read the file dictionary in order to determine the location
of the field. This can affect the performance of your application. If performance is an
issue, use the ReadField() method. For more information about using the
ReadNamedField() method, see Data Conversion in Chapter 2, “Using
UniObjects for .NET.”
UniDynArray ar = fl.ReadNamedFields(“2”,parr);
UniFile fl = us.CreateUniFile("CUSTOMER");
This method corresponds to the UniObjects UnlockRecord method and the BASIC
RELEASE statement.
uFile UnlockRecord( "REC3" );
string aRecordID is the ID of the record to write to. If you do not specify
aRecordID, the record ID is the one set previously by the RecordID method.
string aRecordData is the value to write to the record. If you do not specify
aRecordData, the value to write is the one set previously by the Record property.
After executing the Write() method, call the FileStatus property to determine
the state of record locks during the operation, as follows:
Value Description
This method corresponds to the UniObjects Write method and the BASIC WRITE
and WRITEU statements.
string recID = “2”;
UniDynArray arr = new UniDynArray(us,”abc”);
fl.Write(recID,arr);
int aFieldNumber is the number of the field to which data is to be written. If you
do not specify aFieldNumber, this method writes to field 1.
string aRecordID is the ID of the record to which the data is to be written. If you
do not specify aRecordID, the record ID is the one set previously by the RecordID
property.
Value Description
This method corresponds to the UniObjects WriteField method and the BASIC
WRITEV and WRITEVU statements.
This example writes the string NewFieldValue into field 3 of the record REC3.
int fieldnumber = 5;
string recID = “2”;
UniDynArray arr = new UniDynArray(us,”abc”);
fl.WriteField(recID, fieldnumber ,arr);
string aRecordID is the ID of the record to which the data is to be written. If you
do not specify aRecordID, the record ID is the one set previously by the RecordID
property.
Value Description
Value Description
Value Description
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
UniDictionary Class
The UniDictionary class controls access to UniData and UniVerse dictionary
files. It is an extension of the UniFile class with properties and methods specific to
dictionary files.
For more information about dictionary files and how to use them, see The Database
Environment and Using a Dictionary in Chapter 2, “Using UniObjects for .NET.” For
more information about the fields in a dictionary, see Universe System Description.
Token
Numbe
r Token Description
This property also sets the data portion of the record, primarily to be used for
subsequent Write methods.
Token
Numbe
r Token Description
Token
Numbe
r Token Description
Token
Numbe
r Token Description
This method corresponds to the UniObjects ClearFile method and the BASIC
CLEARFILE statement.
This method corresponds to the UniObjects CloseFile method and the BASIC
CLOSE statement.
If you do not specify a record, the value set by the RecordID property is used.
uFile.DeleteRecord(rec);
This method corresponds to the UniObjects DeleteRecord method and the BASIC
DELETE and DELETEU statements.
string akNameObj is the field name of the secondary index whose information
you want.
For D-type indexes: field 1 contains D as the first character and field 2
contains the location number of the indexed field.
For I-type indexes: field 1 contains I as the first character, field 2 contains
the I-type expression, and the compiled I-type code occupies fields 19
onward.
For both D-type and I-type indexes:
The second value of field 1 is 1 if the index needs to be rebuilt, or an
empty string otherwise.
The third value of field 1 is 1 if the index is null-suppressed, or an
empty string otherwise.
The fourth value of field 1 is 1 if automatic updates are disabled, or an
empty string otherwise.
The sixth value of field 1 contains an S if the index is single-valued or
an M if it is multivalued.
If akNameObj is an empty string, a list of available secondary key indexes on the file
returns as a dynamic array of fields.
This method corresponds to the UniObjects GetAkInfo method and the BASIC
INDICES function.
The first characters of the CODE field indicate the type of field the dictionary record
is defining. Valid types are:
D D-descriptor
I I-descriptor
V (UniData only) V-descriptor
PH Phrase
X (UniVerse only) X-descriptor
string aRecordID is the record ID of the record supplied as data to the Itype
facility.
This method corresponds to the UniObjects IType method and the BASIC ITYPE
function.
This method corresponds to the UniObjects LockFile method and the BASIC
FILELOCK statement.
int aLockFlag is the token number for the lock flag value, as follows:
Token
Numbe
r Token Description
If you do not specify a record ID or dataset, the record is the one set previously by
the RecordID property.
Note: You may need to explicitly unlock the record using the UnlockRecord()
method, depending upon the release strategy value.
This method corresponds to the UniObjects LockRecord method and the BASIC
RECORDLOCKL and RECORDLOCKU statements.
UniDynArray ar = fl.Read(“54637”);
This method corresponds to the UniObjects Read method and the BASIC READ,
READL, and READU statements.
int aFieldNumber is the number of the field to read. Specify field 0 (the
record ID) to check if a record exists.
string aRecordID is the ID of the record whose field value you want to read. If
you do not specify aRecordID, the record ID is the one set previously by the
RecordID property.
This method corresponds to the UniObjects ReadField method and the BASIC
READV, READVL, and READVU statements.
UniFile fl = us.CreateUniFile("CUSTOMER");
UniDynArray ar = fl.ReadField(“2”,3);
string aRecordID is the ID of the record whose field value is to be read. If you
do not specify aRecordID, the record ID is the one set previously by the RecordID
property.
UniDynArray ar = fl.ReadFields(“2”,parr);
string aFieldName is the name of the field to be read. The field must be defined
by a D-descriptor or an I-descriptor in the file dictionary.
string aRecordID is the ID of the record containing the field to be read. If you do
not specify aRecordID, the record ID is the one set previously by the RecordID
property.
Note: This method needs to read the file dictionary in order to determine the location
of the field. This can affect the performance of your application. If performance is an
issue, use the ReadField() method. For more information about using the
ReadNamedField() method, see Data Conversion in Chapter 2, “Using
UniObjects for .NET.”
If ReadNamedField() returns the error UVE_RNF (record not found), the missing
record can be either the data record whose field value you want to read or the
dictionary record defining the field.
UniDynArray ar = fl.ReadNamedField(“2”,”FNAME”);
string[] pFieldNames is the name of the field to be read. The field must be
defined by a D-descriptor or an I-descriptor in the file dictionary.
string pRecordID is the ID of the record containing the field to be read. If you do
not specify aRecordID, the record ID is the one set previously by the RecordID
property.
Note: This method needs to read the file dictionary in order to determine the location
of the field. This can affect the performance of your application. If performance is an
issue, use the ReadField() method. For more information about using the
ReadNamedField() method, see Data Conversion in Chapter 2, “Using
UniObjects for .NET.”
UniDynArray ar = fl.ReadNamedFields(“2”,parr);
UniFile fl = us.CreateUniFile("CUSTOMER");
string aRecordID is the ID of the record you want. If you do not specify
aRecordID, the record is specified by the RecordID property.
UniDynArray aString is the value to be written to the CODE field. The first
characters of the TYPE field indicate the type of field the dictionary record is
defining. Valid types are:
D D-descriptor
I I-descriptor
V (UniData only) V-descriptor
PH Phrase
X (UniVerse only) X-descriptor
This method corresponds to the UniObjects UnlockRecord method and the BASIC
RELEASE statement.
uFile UnlockRecord( "REC3" );
string aRecordID is the ID of the record to write to. If you do not specify
aRecordID, the record ID is the one set previously by the RecordID method.
string aRecordData is the value to write to the record. If you do not specify
aRecordData, the value to write is the one set previously by the Record property.
After executing the Write() method, call the FileStatus property to determine
the state of record locks during the operation, as follows:
Value Description
This method corresponds to the UniObjects Write method and the BASIC WRITE
and WRITEU statements.
string recID = “2”;
UniDynArray arr = new UniDynArray(us,”abc”);
fl.Write(recID,arr);
int aFieldNumber is the number of the field to which data is to be written. If you
do not specify aFieldNumber, this method writes to field 1.
string aRecordID is the ID of the record to which the data is to be written. If you
do not specify aRecordID, the record ID is the one set previously by the RecordID
property.
Value Description
This method corresponds to the UniObjects WriteField method and the BASIC
WRITEV and WRITEVU statements.
This example writes the string NewFieldValue into field 3 of the record REC3.
int fieldnumber = 5;
string recID = “2”;
UniDynArray arr = new UniDynArray(us,”abc”);
fl.WriteField(recID, fieldnumber ,arr);
string aRecordID is the ID of the record to which the data is to be written. If you
do not specify aRecordID, the record ID is the one set previously by the RecordID
property.
Value Description
Value Description
Value Description
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
UniCommand Class
The UniCommand class controls execution of database commands on the server. With
it, users can run UniData or UniVerse commands or stored procedures on the server.
You can run only one command at a time during a session. For more information
about using database commands, see Using Database Commands in Chapter 2,
“Using UniObjects for .NET.”
If you expect a command to generate large quantities of data, you can set the block
size to a manageable value and read the output in blocks. You read successive blocks
with the NextBlock() method. In this case, the CommandStatus property returns
UVS_MORE when the buffer is full, and when you call the Response property, the
next block of command output is read from the server.
If you use the CommandBlockSize property to set the block size to a value other
than 0, the Response property returns a data segment equivalent to the size that is
set. If the command results are more than can fit in one block, call the NextBlock()
method until the CommandStatus property returns UVS_COMPLETE.
If an encryption type is set, all data transferred between client and server for
UniCommand objects is encrypted.
Use the Response property to get the results from executing the command. If an
error occurs, Execute() throws a UniCommandException and the Response
property returns the error message produced by the executed command.
The CommandStatus property gets the current status of the command, that is,
whether it has completed or is waiting for further input.
This example executes the command LIST VOC SAMPLE 10 on the server:
UniCommand runCmd = uSession.CreateUniCommand();
runCmd.Command = "LIST VOC SAMPLE 10";
runCmd.Execute();
This method corresponds to the UniObjects Exec method and the BASIC EXECUTE
statement.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
try
{
us =
UniObjects.OpenSession("localhost","xxx","yyy","demo","udcs");
UniCommand runCmd = us.CreateUniCommand( ) ;
runCmd.Command = "LIST VOC SAMPLE 10" ;
runCmd.Execute();
string reply = runCmd.Response;
Console.WriteLine(reply);
}
catch(Exception e)
{
Console.WriteLine(e.Message +e.StackTrace);
}
finally
{
if(us != null && us.IsActive)
{
UniObjects.CloseSession(us);
UniDataSet Class
UniDataSet is a collection class. It provides a collection interface for sets of
UniRecord objects, which can then be used to perform bulk or batch operations with
one network operation.
int nIndex is the index position for the associated UniRecord object whose status
is to be determined.
string pUniRecID is the record ID for the UniRecord object whose status is to
be retrieved.
int pIndexLoc is the location at which the row is to be inserted in the dataset.
string pUniRecID is the record ID of the element to be removed from the dataset.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
UniDynArray Class
The UniDynArray object lets you manipulate fields, values, and subvalues in a
dynamic array such as a database record or a select list. UniDynArray objects are
used in:
It handles database strings that contain field marks, value marks, and subvalue marks.
The UniDynArray class converts an input string into a series of subobjects, each of
which is inserted into a .NET ARRAYLIST object. Because of this, the dynamic
array needs to be parsed only once, and ARRAYLIST operations can easily manip-
ulate the UniDynArray object.
For more information about the UniDynArray object, see Fields, Values, and
Subvalues in Chapter 2, “Using UniObjects for .NET.”
int a Field is the field whose value marks, subvalue marks, or text marks are to
be counted.
int aValue is the value whose subvalue marks or text marks are to be counted.
This method corresponds to the UniObjects Count method and the BASIC COUNT
function.
int aField is the field whose values, subvalues, or text values are to be counted.
int aValue is the value whose subvalues or text values are to be counted.
It corresponds to the UniObjects Count method and the BASIC DCOUNT function.
int aField is the number of the field to be deleted, or the number of the field
containing the value or subvalue to be deleted.
int aValue is the number of the value to be deleted, or the number of the value
containing the subvalue to be deleted.
This method corresponds to the UniObjects Del method and the BASIC DELETE
function.
int aField is the number of the field to be extracted, or the number of the field
containing the value or subvalue to be extracted.
int aValue is the number of the value to be extracted, or the number of the value
containing the subvalue to be extracted.
public void Insert (int aField, int aValue, int aSubValue, string
aString)
This method inserts a string object into a dynamic array at a specified field
position/value position, moving subsequent fields, values, or subvalues down.
int aField is the number of the field into which data is to be inserted, or the
number of the field into which a value or subvalue is to be inserted.
int aValue is the number of the value to insert, or the number of the value into
which the subvalue is to be inserted.
This method corresponds to the UniObjects Ins method and the BASIC INSERT
function.
int aField is the number of the field whose length is to be retrieved, or the number
of the field containing the value or subvalue whose length is to be retrieved.
int aValue is the number of the value whose length you want, or the number of the
value containing the subvalue whose length is to be retrieved.
int aField is the number of the field to be removed, or the number of the field
containing the value or subvalue to be removed.
int aValue is the number of the value to be removed, or the number of the value
containing the subvalue to be removed.
public void Replace (int aField, int aValue, int aSubValue, string
aString)
This method replaces a field, value, or subvalue with a new field, value, or subvalue.
int aField is the number of the field whose value is to be replaced, or the number
of the field containing the value or subvalue is to be replaced.
int aValue is the number of the value is to be replaced, or the number of the value
containing the subvalue is to be replaced.
This method corresponds to the UniObjects Replace method and the BASIC
REPLACE function.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
// run Count()
int myVal = lDynArray.Count();
// run Dcount()
int myVal2 = lDynArray.Dcount();
// run Extract
UniDynArray real = lDynArray.Extract(1,1,0);
// run Replace
lDynArray.Replace(2, 0, 0, "*");
//run delete
lDynArray.Delete(1, 0, 0);
// run insert
lDynArray.Insert(0, 0, 0, "2500");
}
Catch (Exception ex)
{
//some error, display it
Console.WriteLine(ex.Message);
}
finally
{
// no error
if(us1 != null)
{
UniObjects.CloseSession(us1);
us1= null;
}
}
}
On UniVerse systems, the UniNLSLocale object defines and manages the National
Language Support conventions in use. The five conventions are Time, Numeric,
Monetary, Ctype, and Collate. The UniNLSLocale object allows these five names
to be supplied as a single UniDynArray object, with five fields containing the
relevant locale name. Locale names are derived from the client system and a
defaultable locale identifier.
The UniNLSLocale object is available from the UniSession object via the
UniSession.CreateNLSLocale() method. If NLS is disabled on the server, the
UniNLSLocale object is not available, and CreateNLSLocale() throws an
exception.
If aName is of type string, each category is set to the corresponding string value.
If the string contains only one element and anIndex is specified, only that locale
setting is changed. If anIndex is not specified, all locale categories are set to the
value defined by aName.
int anIndex is an integer representing the category for which the locale is to be set.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
UniNLSMap controls NLS map settings. The UniVerse server uses NLS maps to
determine which map to use for a client’s string data.
The UniNLSMap object is available from the UniSession object. The UniNLSMap
object is available only if NLS is enabled on the server uniConnection.
When the name has been changed successfully, the ServerMapName property and
GetClientMapName() method return the corresponding value.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
UniRecord Class
The UniRecord object controls database record interaction. It contains the UniDy-
nArray object and RecordID.
public UniRecord ( )
This constructs an instance of the UniRecord class with no data in it.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
UniSelectList Class
The UniSelectList object lets you manipulate a select list on the server. Select
lists are described in The Database Environment and Select Lists in Chapter 2,
“Using UniObjects for .NET.”
This method corresponds to the UniObjects ClearList method and the BASIC
CLEARSELECT statement.
uSel.ClearList();
uSel.Select( uFile );
This method corresponds to the UniObjects FormList method and the BASIC
FORMLIST statement.
UniDynArray testArray = testArray = new UniDynArray(uSession,"");
for (int i = 1; i < 10; i++)
{
testArray.Insert(i, "newRec" + i);
}
uSelect.ClearList();
uSelect.FormList(testArray.ToString());
This method corresponds to the UniObjects GetList method and the database
GET.LIST command.
This method corresponds to the UniObjects Next method and the BASIC
READNEXT statement.
UniDynArray testArray = testArray = new UniDynArray(uSession,"");
for (int i = 1; i < 10; i++)
{
testArray.Insert(i, "newRec" + i);
}
uSelect.ClearList();
uSelect.FormList(testArray.ToString());
while (!uSelect.LastRecordRead)
{
string nextRec = uSelect.Next();
counter++;
}
This method corresponds to the UniObjects ReadList method and the BASIC
READLIST statement.
UniFile uFile = uSession.CreateUniFile("FOOBAR");
UniSelectList uSelect = uSession.SelectList(1);
uSelect.Select(uFile);
UniDynArray retList = uSelect.ReadList();
This method corresponds to the UniObjects SaveList method and the SAVE.LIST
command.
This example opens the ORDERS file, creates a select list of its record IDs, then
starts to read records from the file using the select list:
UniFile uFile = uSession.CreateUniFile("ORDERS");
UniSelectList uSelect = uSession.SelectList(0);
uSelect.Select(uFile);
UniDynArray uvr = uFile.Read(uSelect.Next());
This method corresponds to the UniObjects Select method, the BASIC SELECT
statement, and the database SELECT command.
Note: The Select() method does not correspond to the SQL SELECT statement.
If the named secondary index does not exist, the select list is empty. The new select
list overwrites any previous select list and resets the select list pointer to the first
record in the list.
UniDictionary unid is the name of the UniData or UniVerse dictionary file for
which the select list is to be created.
UniFile uniFile is the name of the UniData or UniVerse file for which the select
list is to be created.
string aIndexValue is a value from the secondary index. Records are selected
when aIndexValue matches the value of the indexed field. It is equivalent to the
following database SELECT command:
The new select list overwrites any previous select list and resets the select list pointer
to the first record in the list.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
UniSequentialFile Class
The UniSequentialFile object defines and manages files that are processed
sequentially. A sequential file is an operating system file on the server containing text
or binary data that you want to use in your application. In UniVerse, sequential files
are defined as type 1 or type 19 files.
For more information about using the UniSequentialFile object, see Using
Binary and Text Files in Chapter 2, “Using UniObjects for .NET.” For a program
example that uses the UniSequentialFile object, see Example Using the
UniSequentialFile Object on page 3-154.
Token
Numbe
r Token Description
For example:
UniSession us=null;
try
{
us =
UniObjects.OpenSession("localhost","xxx","yyy","demo","udcs");
UniSequentialFile fl =
us.CreateSequentialFile("BP",”OLDTEST”,true);
catch(Exception e)
{
Console.WriteLine(e.Message +e.StackTrace);
}
finally
{
if(us != null && us.IsActive)
{
UniObjects.CloseSession(us);
The ReadSize value is initially set to 0, which indicates that all the data should be
read in a single block. When the ReadBlk() method finishes, the ReadSize value
is reset to the number of bytes that were actually read. 0 indicates an error or the end
of the file.
Set the value to a suitable number of bytes for the memory available to your appli-
cation. Values less than 0 are treated as 0.
.Warning: If the value is set to 0 and there is not enough memory to hold all the data,
a run-time exception occurs.
Note: Use the ReadSize property before each use of the ReadBlk() method
because the ReadSize value may have been modified previously.
int is the timeout value in seconds. The default value is 0, which means no timeout.
Note: If you enter a value that is too small, a running process may time out. If this
occurs, an error code is returned and the connection to the server is dropped.
int aRelPos is the token number for the pointer’s relative position in a file, as
follows:
Token
Numbe
r Token Description
int aOffset is the number of bytes before or after aRelPos. A negative offset
moves the pointer to a position before aRelPos.
For example:
UniSequentialFile fl =
us.CreateSequentialFile("BP",”OLDTEST”,true);
fl.FileSeek(0,0);
fl.WriteEOF();
int p = Console.Read();
fl.FileSeek(0,0); /* position back to the beginning of file */
This method corresponds to the UniObjects FileSeek method and the BASIC SEEK
statement.
This method corresponds to the UniObjects Open method and the BASIC
OPENSEQ statement.
Upon completion, you can use the ReadSize property to determine the number of
bytes read. Additionally, the UniSequentialFileStatus property returns a status
value, as follows:
Value Description
This method corresponds to the UniObjects ReadBlk method and the BASIC
READBLK statement.
UniSequentialFile fl =
us.CreateSequentialFile("BP",”OLDTEST”,true);
fl.ReadSize = 4096;
UniDynArray ur = fl.ReadBlk();
Console.WriteLine( "Number of bytes read " + fl.ReadSize);
Console.WriteLine ( "Status from readblk " +
uSeq.UniSequentialStatus );
Value Description
1 The end of the file was reached, or the read-size value is 0 or less.
ReadLine Status Values
This method corresponds to the UniObjects ReadLine method and the BASIC
READSEQ statement.
UniSequentialFile fl =
us.CreateSequentialFile("BP",”OLDTEST”,true);
UniSequentialFile fl2 =
us.CreateSequentialFile("BP",”OLDTEST2”,true);
This method corresponds to the UniObjects WriteBlk method and the BASIC
WRITEBLK statement.
UniSequentialFile fl =
us.CreateSequentialFile("BP",”OLDTEST”,true);
fl.ReadSize = 4096;
UniDynArray ur = fl.ReadBlk();
UniSequentialFile uSeq = uSession.openSeq("BP", "TEST”,true);
fl.WriteBlk(ur);
This method corresponds to the UniObjects WriteEOF method and the BASIC
WEOFSEQ statement.
This method corresponds to the UniObjects WriteLine method and the BASIC
WRITESEQ statement.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
}
}
UniSubroutine Class
The UniSubroutine class allows users to run a cataloged BASIC subroutine on the
server. For information about subroutines, see Client/Server Design Considerations
in Chapter 2, “Using UniObjects for .NET.”
This method corresponds to the UniObjects Call method and the BASIC CALL
statement.
UniSubroutine uSub = uSession.CreateUniSubroutine("SAMPLESUBR",
3);
uSub.SetArg(0, "David");
uSub.SetArg(1, "Thomas");
uSub.SetArg(2, "Meeks");
uSub.Call();
int aArgNum is the number of the argument you are requesting. The first argument
is 0.
int aArgNum is the number of the argument you are requesting. The first argument
is 0.
int aArgNum is the number of the argument you are setting. The first argument is 0.
string aArgVal is the value of the argument to pass to the server subroutine.
The argument is passed to the server before making the call. Any argument you do
not specify with the SetArg() method is passed as an empty string.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
uSub.Call();
uSub.ResetArgs();
Console.WriteLine ("Subroutine: Arg0 = " +uSub.GetArg(0));
Console.WriteLine (" Arg1 = " +uSub.GetArg(1));
Console.WriteLine (" Arg2 = " + uSub.GetArg(2));
UniTransaction Class
The UniTransaction object is available from the UniSession object. The
UniTransaction class provides methods to start, commit, and roll back transac-
tions for a session. If a session closes while transactions are active, the server rolls
them back. For any UniSession object, only one transaction can be active at a time.
This method corresponds to the UniObjects Start method and the BASIC BEGIN
TRANSACTION statement.
This method corresponds to the UniObjects Commit method and the BASIC
COMMIT statement.
This method corresponds to the UniObjects Rollback method and the BASIC
ROLLBACK statement.
protected Finalize( )
This method is inherited from Object. It allows an object to attempt to free resources
and perform other cleanup operations before the object is reclaimed by garbage
collection.
Try
{
uSession = UniObjects.OpenSession("localhost","xxx","yyy","demo","udcs");
UniObjects.CloseSession(uSession);
uSession = null;
}
}
UniXML Class
The UniXML class represents an XML representation of UniData data. Using this
class, you can create XML documents and XML Schema documents from UniQuery
or UniData SQL, or directly from a data file. UniData also provides functions to
generate new data, modify data, or generate XML from the UniData database using
the XMAP file.
protected Finalize()
This method is inherited from UniRoot. It allows an object to attempt to free
resources and perform other cleanup operations before the object is reclaimed by
garbage collection.
Chapter
Software Requirements
Hardware Requirements
Installing UniObjects for .NET
Software Requirements
This section lists the software required to support UniObjects for .NET. Both client
and documentation software components are required.
Software Requirement
Microsoft Data Access Compo- Version 2.6 or later required by .NET Framework
nents (MDAC)
4-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch4.fm
2/22/08
Software Requirement
Hardware Requirements
The following table lists the hardware required to support UniObjects for .NET.
Software Requirement
1. Locate the Install.exe file in the installation directory on the UniVerse 10.2
Client CD. Double-click the file to open it.
The IBM UniData installation menu appears.
4-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch4.fm
2/22/08
2. On the installation menu, click UniDK to install the Uni Development Kit.
This starts the InstallShield Wizard for UniDK.
4-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch4.fm
2/22/08
4. To install UniObjects for .NET to the default destination folder, click Next.
Otherwise, to install to a different folder, click Browse to locate a folder and
then click Next.
The Select Components dialog box appears.
5. The UniObjects for .NET check box is selected by default. Clear the check
box for any other components you do not want to install.
6. Click Next.
The Setup Type dialog box appears.
7. By default, the installation program does not overwrite the uci.config and
uvodbc.config files from a previous installation of UniDK.
If you want to overwrite existing files from a previous version of UniDK,
select the Overwrite Preserved Files check box.
4-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch4.fm
2/22/08
8. Click Next.
The Select Program Folder dialog box appears.
9. Select the program folder to which Setup will add the UniObjects for .NET
program icon.
To accept the default program folder, click Next.
Otherwise, type a new folder name or select one from the Existing Folders
list, and then click Next.
The Start Copying Files dialog box appears.
10. If the current settings are satisfactory, click Next to start copying the
program files.
Otherwise, if you need to change a setting, click the Back button to return
to the dialog box in which you want to make a change.
The Setup Status dialog box appears, showing the percentage of files
copied.
4-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch4.fm
2/22/08
When all files are copied, the Setup Complete dialog box appears.
11. The View Release Notes check box is selected by default. If you do not
want to view release notes, clear the check box.
13. Select the Yes option to restart your computer now or the No option to restart
later.
14. Click Finish.
4-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch4.fm
2/22/08
1. Select Start > Settings > Control Panel > Add/Remove Programs.
2. Click Add New Programs.
3. Click the CD or Floppy button.
4. Insert the UniVerse 10.2 Product CD in your CD drive.
5. Click Next.
6. Click the Browse button to locate the uosetup.msi file in the installation
directory on the product CD.
Online help for UniObjects for .NET is available in the uodotnet.chm file. This file
is found in the installation directory (generally the UONET\DOC directory). To view
the online help, double-click the uodotnet.chm file to open it.
The online help is modeled after MDSN Web help, so it has the same look and feel.
A sample of the help window is shown below:
4-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch4.fm
2/22/08
Merge modules are a feature of Windows Installer that provides a standard method
for delivering components, ensuring that the correct version of a component is
installed. A merge module contains a component such as a .dll along with any related
files, resources, registry entries, and setup logic.
Merge modules cannot be installed directly, but rather are merged into an installer for
each application that uses the component. This ensures that the component is
installed consistently for all applications, eliminating problems such as version
conflicts, missing registry entries, and improperly installed files.
You can ensure that an assembly name is globally unique by signing it with a strong
name. The UniObjects for .NET assembly is signed with a strong name using the key
file uodotnet.snk. This file is provided in the UONET\BIN directory on the
UniData product CD.
Guarantee that the name is unique by relying on unique key pairs. No one
can generate the same assembly name that you can, because an assembly
generated with one private key has a different name than an assembly
generated with another private key.
Protect the version lineage of an assembly. A strong name can ensure that
no one can produce a subsequent version of your assembly. Users can be
sure that a version of the assembly they are loading comes from the same
publisher that created the version the application was built with.
Provide a strong integrity check. Passing the .NET Framework security
checks guarantees that the contents of the assembly have not been changed
since it was built. Note, however, that strong names in and of themselves do
not imply a level of trust like that is provided by a digital signature and
supporting certificate, for example.
Chapter
This chapter contains information on using code samples to get up to speed quickly
on UniObjects for .NET.
5-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\Ch5.fm
2/22/08
Quick Guide
Code Samples on the Product CD
Quick Guide
The following code sample written in C# provides a quick guide for software devel-
opers working in UniObjects for .NET.
using System;
using IBMU2.UODOTNET;
UniSession us1=null
try
{
us1=UniObjects.OpenSession(“DENVER\\asmith”,”xxxi”,”localhost”,
“DEMO”,”UDCS”);
//use UniDataSet
string[]sArray={“2”,”3”, “4”};
UniDataSet uSet=fl.ReadRecords(sArray);
UniRecord q2=uSet[“2”];
string sq2=q2.ToString();
UniRecord q3=uSet[“3”];
string sq3=q3.ToString();
UniRecord q4=uSet[“4]’
string sq4=q4.ToString();
//use UniCommand
UniCommand cmd=us1.CreateUniCommand();
cmd.Command=”List VOC SAMPLE 10”;
cmd.Execute();
string response_str=cmd.Response;
Console.WriteLine(“Response from UniCommand:”,response_str);
//test UniDynArray
UniDynArray pArray=us1.CreateUniDynArray(“a”);
pArray.Insert(1,”b”);
pArray.Insert(1,”c”);
pArray.Insert(1,”d”);
Console.WriteLine(“Result from UniDynArray is:
”,pArray.ToString());
UniDynArray ur = pArray.Extract(2);
Console.WriteLine(“Result from UniDynArray Extract is:
“,ur.ToString());
ur=pArray.Extract(3);
Console.WriteLine(“Result from UniDynArray Extract is:
“,ur.ToString());
}
catch(Exception ex)
{
if(us1 !=null && us1.isActive)
{
UniObjects.CloseSession(us1);
us1=null
}
MessageBox.Show(ex.Message);
}
finally
{
if(us1 !=null && us1.IsActive)
{
UniObjects.CloseSession(us1);
}
}
Before opening and running the sample file, you must complete the following steps
to create a virtual folder named Walkthrough_WebAppl in the
\Samples\Walkthrough_WebAppl installation directory:
Before opening and running the sample file, you must complete the following steps
to create a virtual folder named Walkthrough_WebService in the
\Samples\Walkthrough_WebService installation directory:
Error Codes
and Replace Tokens A
UniObjects for .NET provides information on replace tokens for error
codes and global constants that may be useful in your application. They
are contained in the file whose path is
C:\IBM\UniClient\UNIDK\INCLUDE\UVOAIF.TXT. You can add
this file to an application through the Add File option of the File menu.
Error Codes
These are the error codes that can be returned to a UniObjects for .NET application,
together with their replace tokens. Each token should be used with the UniObject-
sTokens prefix—for example, UniObjectsTokens.UVE_NOERROR.
0 UVE_NOERROR No error
22004 UVE_LRR The last record in the select list has been
read
A-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\AppA.fm
2/22/08
A-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\AppA.fm
2/22/08
A-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\AppA.fm
2/22/08
@Variables
The following tokens represent BASIC @variables:
1 AT_LOGNAME @LOGNAME
2 AT_PATH @PATH
3 AT_USERNO @USERNO
4 AT_WHO @WHO
5 AT_TRANSACTION @TRANSACTION
6 AT_DATA_PENDING @DATA.PENDING
7 AT_USER_RETURN_CODE @USER.RETURN.CODE
8 AT_SYSTEM_RETURN_CODE @SYSTEM.RETURN.CODE
9 AT_NULL_STR @NULL.STR
A-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\AppA.fm
2/22/08
A-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\AppA.fm
2/22/08
PID no token Another user holds a shared file lock. The status
value will be the process ID (PID) of the user
holding the lock.
Lock Status Values
A-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\AppA.fm
2/22/08
1 UVT_NLS_TIME Time
2 UVT_NLS_NUMERIC Numeric
3 UVT_NLS_MONETARY Monetary
4 UVT_NLS_CTYPE Ctype
5 UVT_NLS_COLLATE Collate
NLS Locale Values
A-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\AppA.fm
2/22/08
System Delimiters
The following tokens represent database system delimiters:
Character
Value Token Value Meaning
A-17
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\UONET\AppA.fm
2/22/08
Encryption Values
The following tokens set the encryption values:
Index
Index
A C
Absolute() method of UniDataSet Call() method of UniSubroutine
object 3-114 object 2-27, 3-24, 3-155
Account property of UniSession Cancel() method of UniCommand
object 3-34 object 3-24, 3-108
Add() method of UniDataSet case-sensitivity 3-6
object 3-115 CATALOG command 2-26
ADO.NET classes of .NET catalog space 2-26
Framework 1-7 cataloged subroutine 2-8
AfterLast property of UniDataSet class libraries of .NET Framework 1-6
object 3-113 classes
architecture of UniObjects for overview of 3-4
.NET 1-8 UniCommand 3-105
ArgumentsNumber property of UniDataSet 3-112
UniSubroutine object 3-155 UniDictionary 3-76
ASP.NET classes of .NET UniDynArray 3-120
Framework 1-7 UniFile 3-54
ASP.NET Web applications, UniNLSLocale 3-129
creating 1-3, 5-5 UniNLSMap 3-133
assembly naming 4-16 UniObjects 3-31
UniRecord 3-136
UniRoot 3-28
B UniSelectList 3-139
UniSequentialFile 3-146
Base classes of .NET Framework 1-6
UniSession 3-34
BeforeFirst property of UniDataSet
UniSubroutine 3-155
object 3-113
UniTransaction 3-160
Begin() method of UniTransaction
Clear() method of UniDataSet
object 3-160
object 3-115
BlockingStrategy property of
ClearFile() method 3-24
UniSession object 2-19, 3-34
of UniDictionary object 3-82
ByteArrayToUniCodeString() method
of UniFile object 3-60
of UniSession object 3-42
CLEARFILE statement 3-24
ClearList() method of UniSelectList
object 2-20, 3-24, 3-139
client software for Microsoft .NET 1-4
:\Program Files\Adobe\FrameMaker8\UniVerse
10.2A\UONET\uonetIX.fm
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index iii
10.2A\UONET\uonetIX.fm
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
GetRecordStatus() method of InstallShield Wizard for UniDK 4-5 LockStrategy property of UniSession
UniDataSet object 3-116 IPAddress property of UniSession object 2-19, 3-38
GetSM() method of UniDictionary object 3-37 logging and tracing in UniObjects for
object 2-22, 3-85 IsActive() method of UniTransaction .NET 1-11
GetSQLType() method of object 3-25, 3-161
UniDictionary object 2-22, 3-86 IsActive property of UniSession
GetType() method object 3-37 M
of UniDataSet object 3-116 IsDisposed property of UniSession
MacAddress property of UniSession
of UniDictionary object 2-22, 3-86 object 3-37
object 3-38
of UniDynArray object 3-124 IsFileOpen property
managed code and .NET
of UniFile object 3-62 of UniDictionary object 3-77
Framework 1-6
of UniNLSLocale object 3-130 of UniFile object 3-55
MaxOpenFiles property of UniSession
of UniNLSMap object 3-134 of UniSequentialFile object 3-146
object 3-38
of UniObjects object 3-33 IsFileOpen() property 3-25
MemberwiseClone() method
of UniRecord object 3-137 IsRecordLocked() method
of UniCommand object 3-110
of UniRoot object 3-29 of UniDictionary object 3-87
of UniDataSet object 3-119
of UniSelectList object 3-109, 3-141 of UniFile object 3-62
of UniDictionary object 3-103
of UniSequentialFile object 3-150 Item property of UniDataSet
of UniDynArray object 3-127
of UniSession object 3-49 object 3-114
of UniFile object 3-75
of UniSubroutine object 3-157 iType() method 3-25
of UniNLSLocale object 3-132
of UniTransaction object 3-161 of UniDictionary object 3-87
of UniNLSMap object 3-135
global constants A-1 of UniFile object 3-62
of UniRecord object 3-138
of UniRoot object 3-30
of UniSelectList object 3-145
H J of UniSequentialFile object 3-153
HostName property of UniSession J# with Microsoft .NET 1-3 of UniSession object 3-52
object 3-36 of UniSubroutine object 3-158
HostPort property of UniSession of UniTransaction object 3-162
object 3-36 L merge modules 4-16
HostType property of UniSession methods
Last property of UniDataSet
object 3-37 definition of 2-8
object 3-114
equivalent BASIC statements 2-8
LastRecordRead() method of
equivalent UniObjects methods 2-8
UniSelectList object 3-139
I Length() method of UniDynArray
quick reference 3-8
Microsoft Intermediate Language
Iconv() method of UniSession object 3-25, 3-125
(MSIL) 1-6
object 3-25, 3-49 LockFile() method 3-25
Microsoft Visual Studio® .NET
IDEAL flavor accounts 2-4 of UniDictionary object 3-87
2003 1-4
I-descriptors 2-6 of UniFile object 3-63
Microsoft .NET 1-3
evaluated by ReadNamedField() lockflag parameter 1-12
overview of 1-4 to 1-7
method 2-16 LockRecord() method 3-25
moving file pointers 2-23
INDICES statement 3-24 of UniDictionary object 3-88
multivalued fields 2-5
info level of tracing in .NET of UniFile object 3-63
Framework 1-11 locks 2-6
Insert() method and UniObjects 2-18
of UniDataSet object 3-117 overview 2-18
N
of UniDynArray object 3-125 releasing at end of session 2-19 network, reducing traffic 2-26
installing UniOjbects for setting and releasing 2-18 Next() method of UniSelectList
.NET 4-5 to 4-14 setting default locking action 2-19 object 2-20, 3-25, 3-141
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index v
10.2A\UONET\uonetIX.fm
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index vii
10.2A\UONET\uonetIX.fm
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
X
XML classes of .NET Framework 1-7
XML Web services, creating 1-3, 5-6
Symbols
.msi files 4-16
.NET applications, deploying 4-16
.NET Framework
about 1-4 to 1-7
Common Language Runtime
(CLR) 1-5
programming languages 1-5
@variables A-8