Subject: Ch1, why using CollectionBase class?
Posted By: NewTitle2007 Post Date: 8/5/2007 2:18:31 AM
Hi,

 I purchased this great book and I must say it's one of the best books around. Although it could be better by explaining the complete solution step-by-step but I guess it's not for beginners.

In Chapter 1 I saw the authors using the CollectionBase class, why? can't we just use the Generic classes?

one more issue: the stored procedure
CREATE PROC InsertDiaryEntry
(
    @DiaryId INT,
    @EntryDate DATETIME,
    @EntryTitle NVARCHAR(50),
    @EntryText NVARCHAR(2000),
    @NewDiaryEntryId BIGINT = -1 OUTPUT
)
AS
INSERT INTO DiaryEntry (DiaryId, EntryDate, EntryTitle, EntryText)
VALUES(@DiaryId, @EntryDate, @EntryTitle, @EntryText)
RETURN @@IDENTITY

Uses OUTPUT parameter to set the value of @NewDiaryEntryId and also return the same value I don't understand why the authors did that?
Help please

Reply By: Imar Reply Date: 8/5/2007 4:40:19 AM
Hi there,

One of the goals of the book is to show different ways to accomplish things. While generic classes are extremely useful in most scenarios, there are also situations where it makes sense to create your own collection class. This is shown with the ContactCollection class. However, the code would have worked equally well with a List (Of Contact) generics list or another generic collection.

With regards to the procedure, I think it's a bug. I didn't write that chapter, so I am not 100% sure about the reasoning behind the code, but as far as I can tell, you can drop the OUTPUT param. E.g. the following (untested) should work as well:

SPROC

 @EntryText NVARCHAR(2000),
    @NewDiaryEntryId BIGINT = -1 OUTPUT

)

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply By: NewTitle2007 Reply Date: 8/5/2007 5:34:56 AM
Hello Imar,

Thanks for your help. I will try to use Generics later.

Reply By: Imar Reply Date: 8/5/2007 6:32:19 AM
Yeah, later chapters (WebShop, BugBase and others) use Generics a lot more.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004

Go to topic 63678

Return to index page 2
Return to index page 1