Datasheet

Having created a DiaryEntry object, saving it involves simply calling the Save() method. As with the
Save() method of the Contacts class, the DiaryEntry class will work out whether it’s a new diary
entry that needs to be inserted into the database, or an existing entry that needs to be updated. As well
as enabling retrieval of one diary entry’s details, the
DiaryEntry class provides additional methods for
getting details of a number of diary entries as either a collection or as a DataSet by returning a
sqlDataReader object. The methods of this class are explained in the following table:
Method Return Type Description
Save() None Saves a fully populated
DiaryEntry object. If it’s a
new entry,
Save() calls
InsertNewDiaryEntry
sub and the details are
inserted in to the database.
The new
DiaryEntryId is
returned from the database
and entered in to
mDi-
aryEntryId
.
If the entry already exists
in the database,
Save()
calls UpdateContact,
which updates the
database values with those
in the DiaryEntry object.
GetDaysInMonthWithEntries(ByVal Boolean Array Shared method that
DiaryId As Integer, ByVal Month returns a Boolean
As Integer, ByVal Year As
Integer)
array detailing which days
have a diary entry associ-
ated with them. The array
index matches with the
day of the month (1 is the
first of the month, 2 the
second, and so on).
GetDiaryEntriesByDate(ByVal SqlDataReader Shared method
DiaryId As Integer, ByVal that returns a
FromDate As Date, ByVal ToDate SQLDataReader object
As Date) populated with rows from
the database detailing
diary entries between the
FromDate and ToDate
arguments.
12
Chapter 1
04_749516 ch01.qxp 2/10/06 9:11 PM Page 12