AddressBook
by Mai Nguyen, NeXT Developer Support Team

Overview

In order to run this example, you need to have a SYBASE server with a pubs database installed.  The pubs database is a sample database provided with the SYBASE limited server package. 

After you are properly connected to the Sybase server, you can perform operations such as Select, Insert, Update or Delete. Select is performed by clicking on a particular item in the scrollview, which will then display the person's record (last name, first name, social security,  phone, address, state of residence, zip code).  You have to fill in all these fields when adding a record. Text input is not validated since it is beyond the scope of this small example.
 
Note that this example only uses the DBKit Access Layer, which is useful to know if you need to create your own front-end to a database server. With the DBKit standard UI objects (TableView, DBModule), you could also create a similar example without much programming.
 
Program Organization

Major Classes in the Application

Controller	A general manager object.  A subclass of the Object class.  Performs miscellaneous initialzations, adding and deleting records at a high level.

 AddressView	A subclass of  the ScrollView class with a matrUD f textfield cells. It handles lower level operations for adding, updating and deleting records. 

Other Peculiarities
The primary key for inserting a new record is the social security number. It is not possible to insert a new record with a duplicate id (or social security number). 
In order to load an Adaptor dynamically, you need to add the OTHER_LDFLAGS definition (see the Makefile.preamble). You also need to add the libdbkit_s.a library into your PB.project under libraries in order to use the DBKit API. 

Topics Of Interest

The purpose of this example is to show you some simple examples of the usage of the DBKit Access Layer:

- How to get connected to the SYBASE server via a default login string 
See the method appDidInit: in the file Controller.m.

- How to fetch the data from a  database using a DBRecordList object
See the method loadCellsFrom: in the file AddressView.m

- How to view all the values inside a record in a record list using the DBValue object
See the method showInfo: in the file AddressView.m

- How to add a new record to a database via the DBRecordList object
See the method addRecordFrom:at:  in the file AddressView.m

- How to delete an existing record to a database via the DBRecordList object
See the method deleteSelectedRecord:  in the file AddressView.m

- How to update an existing record to a database via the DBRecordList object
See the method updateRecordFrom:at:  in the file AddressView.m

- How to set up a database delegate to report errors and SQL queries generated by the Sybase adaptor:
See the file Controller.m

Change History
May 1992		Upgraded to libdbkit-33