Datasheet

It has two constructors, outlined in the following table:
Constructor Description
New(ByVal Diaryid as Integer) Creates a new Contact object with all properties set to
their default values.
New(ByVal ContactId As Long) Creates a new Contact object with its properties retrieved
from the database using the argument ContactId.
Having created a
Contact object, saving it involves simply calling the Save() method. The class will
work out whether it’s a new contact that needs to be inserted into the database, or an existing one that
needs to be updated. In addition to the
Save() method, the Contacts class contains two Delete()
methods, as well as two GetContacts() methods, all of which are outlined in the following table:
Method Return Type Description
Save() None Saves a fully populated Contact
object. If it’s a new contact, Save()
calls InsertNewContact sub, and
the details are inserted into the
database. The new ContactId is
returned from the database and
entered into
mContactId. If the con-
tact already exists in the database,
Save() calls UpdateContact, which
updates the database values with
those in the Contact object.
DeleteContact() None Deletes from the database the Con-
tact
object with ContactId equal to
mContactId of the object. Contact
object’s values are re-initialized to
their defaults.
DeleteContact(ByVal None Shared method that deletes the
ContactId As Long) Contact object from the database
with a ContactId value equal to the
ContactId argument of the method.
GetContactsByFirstLetter(ByVal SqlDataReader Shared method that returns a
DiaryId As SqlDataReaderobject populated
Integer,Optional ByVal with a list of contacts whose
FirstLetterOfSurname surname’s first letter matches the
As Char) FirstLetterOfSurname argu-
ment.This argument is optional; if
left off, all
Contact objects regard-
less of surname’s first letter are
included in the DataSet’s rows.
Table continued on following page
9
The Online Diary and Organizer
04_749516 ch01.qxp 2/10/06 9:11 PM Page 9